我反向工程一个Android应用程序与APKTool并获得.Smali文件作为源$ C $ C输出。我转换了.Smali文件与应用程序进行.java文件。我能够成功地编辑.java文件,但现在我想将它们转换回到.Smali这样我就可以重新编译与新.Smali文件的应用程序。当我刚刚离开的.java文件中,有不重新编译,并给出了一些错误。我找不到任何有关在互联网上进行编译的.java到.Smali,所以我希望你们能帮助我。
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.
感谢你在前进,
您可以编译使用普通的java编译器的Java类,然后使用Android的DX实用工具将编译后的.class文件转换成一个DEX文件。然后在DEX文件运行baksmali产生smali文件。
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.
例如,假设您有以下code名为HelloWorld.java一个java文件:
For example, let's say you have the following code in a java file named "HelloWorld.java":
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
要转换为smali:
javac HelloWorld.java
dx --dex --output=classes.dex HelloWorld.class
baksmali classes.dex