Brief analysis, sharing of the process of decompiling Android APK

Brief analysis, sharing of the process of decompiling Android APK

As a technical and product staff member of the company, I am really envious of the excellent Android APK developed by others. During the Android development process, I also want to learn how others create those beautiful animations and layouts, or product logic, so I recently learned how to decompile APK. I only use it for learning and reference to improve product competitiveness, and it will not be used for any illegal intentions.

First download the decompilation software apktool, dex2jar, jd-gui to decompile the APK

Tool Introduction:

apktool: resource file acquisition, can extract image files and layout files for use and viewing, its principle details: (http://my.oschina.net/1590538xiaokai/blog/467830)

dex2jar: decompile apk into java source code (convert classes.dex into jar file)

jd-gui: View the jar file converted from classes.dex in APK, that is, the source code file

Decompilation process:

1. Decompile apk to get the source code, pictures, XML configuration, language resources and other files of the program

Download apktool from the above tools, decompress it to get 3 files: aapt.exe, apktool.bat, apktool.jar, put the APK file to be decompiled in the directory, open the command line interface (Run-CMD), locate the apktool folder, and enter the following command: apktool.bat d -f test.apk test (test.apk in the command refers to the full name of the APK file to be decompiled, and test is the name of the directory where the resource files are stored after decompilation, that is: apktool.bat d -f [apk file] [output folder])

It means the acquisition is successful. Then you will find a test file in the folder. Click it to view all the resource files of the application.

If you want to repackage the decompiled file into an APK, you can enter apktool.bat b test (the folder you compiled), and the effect is as follows: After that, you can find two more folders under the previous test file: build dist (which stores the packaged APK file)

2. Decompile Apk to get Java source code

Download dex2jar and jd-gui from the above tools, unzip the APK to be decompiled, change the suffix to .rar or .zip, and unzip it to get the classes.dex file (it is the java file compiled and packaged by the dx tool), put the obtained classes.dex into the previously unzipped tool dex2jar-0.0.9.15 folder, locate the directory where dex2jar.bat is located in the command line, enter dex2jar.bat classes.dex, the effect is as follows: a classes_dex2jar.jar file will be generated in the changed directory, and then open the jd-gui.exe in the tool jd-gui folder, and then use the tool to open the previously generated classes_dex2jar.jar file to see the source code, the effect is as follows: the obfuscated effect diagram (the class file name and the method name in it will be named in the style of a, b, c...).

3. Graphical decompilation of apk

The above steps 1 and 2 describe command line decompilation of apk. Now we provide a graphical decompilation tool: Androidfby. First, download the above decompilation tool package, open the Androidfby directory, double-click the Android decompilation tool.exe, and you can browse and open the apk to be decompiled. Through decompilation, you can find out what third-party library files the application uses, how its code is written, and so on.

[[140088]]

Of course, some APKs are obfuscated to avoid being decompiled by others. Because many criminals start pirating an APP by decompilation. So from the perspective of mobile application security, in order to prevent others from understanding the layout and logic of your APK, some decompilation protection measures should be taken, especially to avoid being seen by competitors. If developers do not want to be decompiled by others and improve the security of APK, encryption protection can be used.

As an ordinary mobile developer, the purpose of decompilation is just to understand the general idea of ​​other people's applications, which is beneficial rather than harmful to development work.

<<:  A detailed discussion of environmental sensors on mobile phones and related APIs in W3C

>>:  How to improve the style of APP interface in details?

Recommend

Nokia launches Android tablet: Escape and comeback

Only half a year after selling its device and ser...

Some people were silent when they saw this picture, while others were envious.

The World Cup is over. I wonder if you still reme...

Android phones collect and transmit large amounts of data, study shows

[[428880]] Researchers from Trinity College Dubli...

600 stores’ private live broadcasts summarized these 6 live broadcast methods!

With the popularity of the live streaming industr...

Mayu product operation analysis!

Menstruation is a very private and important matt...

The battle to protect smart homes begins with Google's acquisition of Dropcam

The smart home industry was a little restless in ...

Hardcore Media-Product Selection Course [What Products Bring Their Own Traffic]

Hardcore Media - Product Selection Course [What Pr...

The most practical seed user operation method

I have been wanting to talk about the seed user o...

Using iPhone = Protecting the Earth

June 5th of every year is World Environment Day, b...

Dark color vs. light color, which umbrella is more sun-proof?

The most frustrating thing about summer is that e...

How can educational institutions carry out good community operations?

With the continuous acceleration of the developme...