Android APK decompilation is as simple as this (with the picture), androidapk

Source: Internet
Author: User

Android APK decompilation is as simple as this (with the picture), androidapk

In the process of learning Android development, you will often learn how other people's applications are developed. Those beautiful animations and exquisite la S may make you easy to understand. As a developer, you may want to know how these effects are implemented. In this case, you can decompile and view the modified APK. The following is a simple tutorial for my reference.

(Note: decompilation is not intended for developers to reinstall an application for cracking. The main purpose is to promote developers' learning, learn from good code, and improve their self-development level .)


Test environment:

Win 7


Tools used:

On CSDN:

Download apktool (resource file retrieval)

Dex2jar (source code file retrieval) download

Jd-gui (Source Code view) download

 

Android decompilation integration kit (latest)Download

 

Latest official version:

Apktool (google code)

Dex2jar(Google code)

 For the latest jd-gui (google code) version, see the official website.


Tool introduction:

Apktool

Purpose: Obtain resource files. You can extract image files and view layout files.

Dex2jar

Purpose: decompile the apk into the java source code (classes. dex is converted into a jar file)

Jd-gui

Purpose: view the jar file converted from classes. dex in the APK, that is, the source code file.


Decompilation process:

I. apkDecompiledProgram source code, images, XML configuration, language resources, and other files

Download apktool from the preceding tool and decompress the three files: aapt.exe, apktool. bat, and apktool. jar. Put the decompiled APK file in this directory,

Open the command line interface (run-CMD), Go to the apktool folder, and enter the following command:Apktool. bat d-f test.apk test


(In the command line, test.apk indicates the full name of the APK file to be decompiled. test indicates the Directory Name of the decompiled resource file, that is, apktool. bat d-f [apk file] [Output Folder]).

It indicates that the test file is successfully obtained, and a test file is added to the folder. You can click it to view all the resource files of the application.

If you want to repackage the decompiled file into an apk, you can: EnterApktool. bat B test(You can compile the folder). The effect is as follows:


Then we can find two more folders in the previous test file:

Build

Dist (which stores the packaged APK files)


Ii. ApkDecompilationObtain the Java source code

Download the dex2jar andJd-gui, decompress

Change the suffix of apkto to .rar or. zip, decompress it, and obtain the classes. dex file (which is compiled by the java file and then packaged by the dx tool ).Classes. dex is placed in the dex2jar-0.0.9.15 folder of the tool that was previously decompressed,

Locate the directory of dex2jar. bat in the command line and enter dex2jar. bat classes. dex. The effect is as follows:

AAfter opening the jd-gui.exe file in the tool jd-guifolder, use the tool to open the previously generated classes_dex2jar.jar file to see the source code. The effect is as follows:

Obfuscated (the class file name and the method names in it are all named in a, B, c... and other styles ):



Iii. graphical decompilation apk (I have never used it)

Steps 1 and 2 above describe the command line decompilation apk, and now provides a graphical decompilation tool: Androidfby

First, download the decompilation tool package, open the androidfbydirectory, and double-click the androiddecompilation tool .exe to open the decompilation apk.


Through decompilation, you can know the library files used by the application, how the code is written, and so on.

However, if the APK is obfuscated, the name of the class file you see and the method name in it will be a, B, c .... you can find the interface code you want to know. It may be very difficult to find the code, but a general idea will be obtained, with this idea, you can try it on your own.

I once wanted to write a celebrity interface layout similar to CHANGBA, but I had no idea how to write it for the first time. Even if his code was obfuscated, I also see that it is implemented by setting different ITEM la s through the LISTVIEW TYPE. Many references may use overwrite VIEW to achieve the effect. You can get his general idea, which is beneficial to your development.

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.