My system is ubuntu12.04
1. Required Tools
1)Apktool, function: decompile the required resource files and layout settings files for APK, etc.
: https://code.google.com/p/android-apktool/downloads/list
Need to download apktool1.5.2.tar.bz2 and apktool-install-linux-r05-ibot.tar.bz2 two files, and put the extracted files in the same folder .
2)Dex2jar, function: decompile the jar file, that is, the APK source program file byte code,
: http://code.google.com/p/dex2jar/downloads/list
3)Jdgui, function: View the Dex2jar anti-compiled jar file, use the tool can see the corresponding Java source code, This I did not find on the official website, and then I downloaded on the Internet, but tried to use. Click Open, as shown in:
2. Anti-compilation process
1) decompile the resource file
Using the Apktool tool, enter the directory where Apktool is located, using the following command:
./apktool d./xxx.apk (the path where the APK resides)
D represents decode, in the current directory will generate a directory called XXX, which is the various anti-compiled resource files, where res represents a resource file,Smali represents the source code, but the bytecode, can not be viewed directly.
take my experiment as an example, as shown in:
A directory app-debug is generated at this time in the current directory.
2) Anti-compilation of source code
A) because the APK file is actually used zip for packaging compression generated files, so first rename the xxx.apk file to Xxx.zip file, and unzip it.
b) into the extracted directory, which has a classes.dex file, which is the Java file compiled and then packaged with the DX tool, the source code is included in this file.
c) Copy the file Classes.dex generated in the previous step to the root of the Dex2jar tool and decompile it with the following command:
./dex2jar.sh D Classes.dex
A Classes_dex2jar.jar file is generated in the current directory
d) Click to open the Jdgui tool, this is a graphical tool, and then open the above Classes_dex2jar.jar file to see the source code of the apk corresponding.
For my experiment is as follows:
The source code and the anti-compiled code are compared as follows (white is the anti-compilation content, black is the original content):
Linux under anti-compilation Android APK