将.java转换为.smali

时间:2019-06-17 12:37:03

标签: java android smali

正如标题中所述,我正在尝试将Java文件转换为.smali文件,因此这些是我尝试从Android Studio终端启动的命令:

javac HelloWorld.java

dx --dex --output=classes.dex HelloWorld.class

baksmali classes.dex

但是当我启动第二个命令时,出现此错误:

  

bash:dx:找不到命令

此外,我尝试通过以下方法将文件直接编译为smali:在Android Studio上转到Build/compile to smali,这是我得到的错误:

  

错误:内部错误:(java.lang.ClassNotFoundException)com.google.wireless.android.sdk.stats.IntellijIndexingStats $ Index   java.lang.ClassNotFoundException:com.google.wireless.android.sdk.stats.IntellijIndexingStats $ Index>     在java.net.URLClassLoader.findClass(URLClassLoader.java:381)     在java.lang.ClassLoader.loadClass(ClassLoader.java:424)     在java.lang.ClassLoader.loadClass(ClassLoader.java:357)     在com.intellij.util.indexing.counters.IndexCounters。(IndexCounters.java:34)     在com.intellij.util.indexing.impl.MapReduceIndex。(MapReduceIndex.java:86)     在org.jetbrains.jps.backwardRefs.index.CompilerReferenceIndex $ CompilerMapReduceIndex。(CompilerReferenceIndex.java:214)     在org.jetbrains.jps.backwardRefs.index.CompilerReferenceIndex。(CompilerReferenceIndex.java:73)     在org.jetbrains.jps.backwardRefs.JavaCompilerBackwardReferenceIndex。(JavaCompilerBackwardReferenceIndex.java:12)     在org.jetbrains.jps.backwardRefs.JavaBackwardReferenceIndexWriter.initialize(JavaBackwardReferenceIndexWriter.java:74)     在org.jetbrains.jps.backwardRefs.JavaBackwardReferenceIndexBuilder.buildStarted(JavaBackwardReferenceIndexBuilder.java:40)处     在org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:358)     在org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178)     在org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)     在org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)     在org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:135)     在org.jetbrains.jps.cmdline.BuildMain $ MyMessageHandler.lambda $ channelRead0 $ 0(BuildMain.java:229)     在org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda $ executeOnPooledThread $ 0(SharedThreadPoolImpl.java:42)     在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)     在java.util.concurrent.FutureTask.run(FutureTask.java:266)     在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)     在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)     在java.lang.Thread.run(Thread.java:745)

关于如何进行这项工作的任何想法?或任何其他工具将.java转换为.smali?

1 个答案:

答案 0 :(得分:1)

这对我有用:

我只需要找到Linux上~/Android/Sdk/build-tools/$version中的命令dx,但首先要确保已安装android-sdk (通常位于Linux上的~/android/sdk中),然后使用

运行dx

./dx --dex --output=classes.dex path_to_source_file.class(如果您与dx位于同一目录中