将 .Java 文件转换为 .Smali 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29051781/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert .Java file to .Smali file
提问by
I reverse engineered an Android application with APKTool and got .Smali files as source code output. I converted the .Smali files with an application to .Java files. I was able to succesfully edit the .Java files but now I want to convert them back to .Smali so I can recompile the application with the new .Smali files. When I just leave the .Java file there it doesn't recompile it and gives some errors. I couldn't find anything about compiling .Java to .Smali on the internet so I hope you guys could help me.
我使用 APKTool 对 Android 应用程序进行了逆向工程,并获得了 .Smali 文件作为源代码输出。我将带有应用程序的 .Smali 文件转换为 .Java 文件。我能够成功编辑 .Java 文件,但现在我想将它们转换回 .Smali 以便我可以使用新的 .Smali 文件重新编译应用程序。当我将 .Java 文件留在那里时,它不会重新编译它并给出一些错误。我在互联网上找不到任何关于将 .Java 编译为 .Smali 的信息,所以我希望你们能帮助我。
Thank you in advance,
先感谢您,
采纳答案by JesusFreke
You can compile the java classes using a normal java compiler, and then use Android's 'dx' utility to convert the compiled .class files to a dex file. And then run baksmali on the dex file to produce the smali files.
您可以使用普通的 java 编译器编译 java 类,然后使用 Android 的“dx”实用程序将编译后的 .class 文件转换为 dex 文件。然后在 dex 文件上运行 baksmali 以生成 smali 文件。
For example, let's say you have the following code in a java file named "HelloWorld.java":
例如,假设您在名为“HelloWorld.java”的 java 文件中有以下代码:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
To convert it to smali:
将其转换为 smali:
javac HelloWorld.java
dx --dex --output=classes.dex HelloWorld.class
baksmali classes.dex
回答by Dermot Blair
Try java2smali: https://github.com/ollide/intellij-java2smali
试试 java2smali:https: //github.com/ollide/intellij-java2smali
It is an application used to convert Java to Smali.
它是一个用于将 Java 转换为 Smali 的应用程序。