Android APK decompilation to view source code and resource files

Source: Internet
Author: User

This topic describes howDecompile the Android Application to view the source code, resource files, and XML files, modify the files, and package them into an APK.. We encourage people to decompile to learn others' designs, rather than confusing the market after changing the app shell. You can also directly use the anti-droid compiled by netizens.

 

Android APK is actually a Zip file, which can be decompressed and decompiled to view source code and resource files. For example:

Right-click the APK file and select Winrar compressed file manager as follows:

Is it similar to the program's directory structure? the source code has been compressed into the classes. dex file. Here we can directly view the image files under res, but the source code cannot be viewed, and the opening of xml files such as AndroidManifest. xml is also garbled.

 

Toolkit needed (as of the latest version in), including dex2jar, jd-gui, and apktool. You can also download the latest version as needed below.
1. View Source Code
(1) modify the file suffix .apk to .zip and decompress it with winrar to record the path of classes. dex.
(2) Use the android-reverse-trinea \ dex2jar-0.0.9.13 in the Toolkit or download the latest dex2jar and unzip it and run

Dex2jar classes. dex path
1 Dex2jar
Classes. Dex path

As follows:

As follows:


Classes_dex2jar.jarwill be generated in the classes.dex directory. Open this file with jd-gui.exe (use jd-gui in the Toolkit or download the latest version), as shown below:

We can get a general understanding of the code structure. Although the source code is poorly readable after proguard obfuscation, we can still find some information through keywords (non-obfuscated class names. However, jd-gui does not support source code search. It only supports search types, constructors, constants, attributes, and methods.

 

2. View resource files and XML files
(1) Use the Android-reverse-trinea \ apktool-1.5.2-windows in the Toolkit or download the latest apktool (you need to download the apktool and the corresponding platform dependency package at the same time, decompress the package to the platform dependency package in the apktool. jar to the apktool directory), and run

Apktool. Bat D-F xxx.apk xxx
1 Apktool. bat
D-f
Xxx.apk
Xxx

In this example, "dashboard" is unwrapped, "xxx.apk" is the path of the APK to be decompiled, and "XXX" is the name of the target folder. (apktool does not support Chinese directories:

The result will be apktool again. the Weixin folder is generated in the directory where BAT is located. Now, you can view the XML resources correctly (including all resources under Res, such as images, drawable, layout, value, and menu, for example, androidmanifest. XML

 

3. Modify the package and package it into an APK.

Still use the apktool in step 2. The command is as follows:

Apktool. Bat B xxx
1 Apktool. bat
B xxx

B Indicates build, xxx indicates the folder that is decompressed in step 2. We can modify a file and repackage it.
After packaging, the build and DIST folders are generated under the xxx directory. Dist stores the re-generated APK, and build stores the specific composition information of the APK.
Here we can simply replace the resource or modify the code by modifying smali. Do not do anything bad _*.

Original article: http://www.trinea.cn/android/

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.