Decompilation of Android applications
The graduation project accidentally chose the development direction of the smartphone, and the platform chose Android, So I recently learned a lot about Android program development. However, as a lazy, easy to give up halfway, Android's built-in system is still a bit huge and wants to develop a unique application of its own, the difficulty is really great for me, cainiao. Therefore, it is inevitable that the idea of "the Stone of another hill can attack the jade" will emerge.
The instructor led by Biji said: programmers who write their own code are not good programmers. It is a good programmer to use other people's code and change it into your own. I don't know whether it makes sense. It's just my heart. Lazy people have their own lazy ways of life. There are only a few geniuses, while lazy people are mostly likes. Naturally, I am the majority.
However, to modify others' code, you must know its code. Therefore, we need to decompile the Android Application. Fortunately, andorid is an open platform and The Decompilation process is much simpler than the normal program. Let's talk about this simple process.
Basic knowledge
The app suffixes installed on Android are all APK (Android Application packageextensions). Every app to be installed on the Android platform must be compiled into a single file and suffixed with .apk. In fact, this APK file is a disguised zip package. You can use WinRAR to open the file structure. You can usually see the following content:
|-Androidmanifest. xml
|-META-INF
|-Cert. RSA
|-Cert. SF
|-Manifest. MF
|-Classes. Dex
|-Res
|-Drawable
| '-Icon.png
|-Layout
| '-Main. xml
|-Resources. ARSC
Meaning of each document content will not go into details, you can see this article http://www.ophonesdn.com/article/show/38
We usually need to decompile two parts: classes. DEX and Main. xml. One is the bytecode compiled by Java through Google's self-built virtual machine Dalvik, and the other is the layout file. There are more than one large program layout file. Here we only talk about one file, and others are similar.
Required tools
1. decompile the DEX file into a jar file. (Dex2jar)
2. decompile jar into a Java tool. JD-GUI)
3. axmlprinter2
The three download links are:
Http://code.google.com/p/dex2jar/
Http://java.decompiler.free.fr /? Q = jdgui
Http://code.google.com/p/android4me/downloads/detail? Name1_axmlprinter2.zip & can = 2 & Q = (this file seems to be unavailable. If you are interested, you can download it from csdn)
Decompilation of XML files
The XML file in the APK file is compressed, So if you open it directly, you will see some garbled characters, so you need to use the axmlprinter2 tool.
After installing the Java environment, run cmd to go to the directory where you decompress the APK file and run the following command (note that the axmlprinter2.jar file also needs to be used ):
Java-jar axmlprinter2.jar main. xml
After the program is successful, an XML decompiled file will appear in cmd.
Classes. Dex file Decompilation
The android simulator provides dexdump, A decompilation tool for Dex files. First, start the android simulator, and use the ADB push upload simulator to view the DEX file. Then, log on to the simulator using the ADB shell, find the DEX file to be viewed, and execute dexdump XXX. Dex. However, the readability of the result is very poor.
So we use two tools, dex2jar and JD-Gui.
Decompilation steps:
1. Extract the classes. Dex file from the APK and decompress the APK file. Put it in the dex2jar directory, open cmd, run dex2jar. Bat classes. Dex, and generate classes. Dex. dex2jar. jar.
2, run the JD-GUI tool, open the jar file above, you can see the source code.
On the JD-GUI we can see a bunch of a B c d ...... The tree structure of, these are not, really look at the activity.