Android APK decompilation (with image)

Source: Internet
Author: User

During this time, I was learning about Android Application Development. I was thinking that since it was developed in Java, it should be a good decompilation to getSource codeGoogle, it is really simple. The following is my practice process.

I solemnly declare that the purpose of the post is not to crack the software of other people, but it is completely a learning attitude, but it seems that some foreign software can be customized in this way.


1. decompile the APK to get the Java sourceCode
First download two tools: dex2jar and JD-GUI

The former is to convert the classes. Dex in the APK into a jar file, and the JD-GUI is a decompilation tool, you can directly view the source code of the jar package. The following are:

Dex2jar:Http://laichao.googlecode.com/files/dex2jar-0.0.7-SNAPSHOT.zip

JD-GUI:Http://laichao.googlecode.com/files/jdgui.zip

Procedure:

First, change the suffix of the APK file to zip, decompress it, and obtain the classes. Dex, which is compiled by the Java file and then packaged by the DX tool;

Decompress the downloaded dex2jar and copy classes. Dex to the directory where dex2jar. bat is located. Locate the directory of dex2jar. bat under the command line.

Run

Dex2jar. Bat classes. Dex

Generate

Classes. Dex. dex2jar. Jar

The jar file is generated as follows:

 

Run jd-gui(jd-gui.exe) and open the jar package generated above. The source code is displayed.


Helloandroid source code (APK source code before compilation) is as follows:

 


Ii. decompile APK generationProgramSource code and images, xml configuration, language resources, and other files

This is especially useful if it is just a Chinese software.

First, download the tool. This time, apktool is used.

: Http://code.google.com/p/android-apktool/downloads/list

Download: apktool1.4.1.tar.bz2 and apktool-install-windows-r04-brut1.tar.bz2 (both packages are downloaded)

Procedure:

Decompress the downloaded two packages to the same folder. There should be three files: aapt.exe, apktool. bat, and apktool. jar.

Locate the apktool. Bat folder in the command line and enter the following command: apktool d c: \ *. APK c: \ * folder, for example:

 

Command Line explanation: apktool d [APK file] [Output Folder]

The decompiled file is as follows (androidmanifest. XML is used as an example ):

Note: files to be decompiled must be placed in the root directory of drive C.

Re-package the decompiled file into an APK. You can simply enter the apktool B c: \ *** folder (the folder you compiled). The command is as follows:

 

The package APK file is in the directory c: \ helloandroid and two folders are generated:

Build

Dist

In this example, package the generated helloandroid.apk. In the above Dist folder, OK

Note:This android decompilation tutorial is based on Windows 7 Ultimate 64bit.

Download the decompilation Toolkit

In addition, as an application developer, you certainly do not want your code to be decompiled. The next blog will show you how to put obfuscated code in decompilation:

How does Android prevent the APK program from being decompiled?

Related Article

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.