Convert .Java file to .Smali file

I redid the Android application with APKTool and got the .Smali files as source code. I converted the .Smali files with the application to .Java files. I was able to successfully edit the .Java files, but now I want to transfer them back to .Smali so that I can recompile the application with the new .Smali files. When I just leave the .Java file, it does not recompile it and gives no errors. I could not find anything about compiling .Java to .Smali on the Internet, so I hope you guys could help me.

Thank you in advance,

+6
source share
2 answers

You can compile java classes using a regular java compiler, and then use the Android dx utility to convert the compiled .class files to a dex file. And then run baksmali in the dex file to create smali files.

For example, let's say you have the following code in a java file called "HelloWorld.java":

public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } 

To convert it to smali:

 javac HelloWorld.java dx --dex --output=classes.dex HelloWorld.class baksmali classes.dex 
+12
source

Try java2smali: https://github.com/ollide/intellij-java2smali

This is the application used to convert Java to Smali.

+12
source

Source: https://habr.com/ru/post/983796/


All Articles