Decompilation of Android applications

Source: Internet
Author: User
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
|-Cert. RSA
|-Cert. SF
|-Manifest. MF
|-Classes. Dex
| '-Icon.png
| '-Main. xml
|-Resources. ARSC

Meaning of each document content will not go into details, you can see this article

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:// /? Q = jdgui
Http:// & 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.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.