Decompile APK in Android

Source: Internet
Author: User

I. Method 1:
Tool download: requires the dex2jar and JD-GUI tools

Dex2jar: http://laichao.googlecode.com/files/dex2jar-0.0.7-SNAPSHOT.zip
JD-GUI:
Windows JD-GUI: http://laichao.googlecode.com/files/jdgui.zip
Linux JD-GUI: http://laichao.googlecode.com/files/jd-gui-0.3.2.linux.i686.tar.gz

Steps:

1. First find classes. Dex in the Android software installation package:
Change the. APK file name to .zip and decompress it to obtain the classes. dex file, which is compiled by a Java file and then packaged by the DX tool. Now we use the two tools mentioned above to export the Java source file in reverse direction.

2. Copy classes. Dex to the directory where dex2jar. bat is located.
In command line mode, locate the directory where dex2jar. bat is located and run dex2jar. Bat classes. Dex to generate classes. Dex. dex2jar. jar.

3. Run the JD-GUI tool (it is green without installation)
Open the JAR File above and you will see the source code

Ii. Method 2: (recommended)
Decompile the source code and images, xml configuration, language resources, and other files of the APK Generation Program.

Reprinted from: http://blog.sina.com.cn/s/blog_5752764e0100kv34.html

Download tool:

Download the following packages at http://code.google.com/p/android-apktool/: apktool-1.0.0.tar.bz2and apktool-install-windows-2.20.r01-1.zip.
After downloading and unzipping, copy the four files to the C: \ Windows folder as recommended by the author.

This tool is written by Java. Your computer is installed with jre1_jdk and added to the path of java.exe in the system environment variation path.

After the above preparations are completed, you can use it to decompile the APK. Here I will use the APK of the live wallpaper for demonstration.

If you have used a live wallpaper, you may find that when you set the wallpaper, the page displays a problem: "Live Wallpaper", Chinese Text displayed as "Current Wallpaper" on your mobile phone ". This is caused by the translation error of the dynamic wallpaper selector "livewallpaperspicker.apk.

(Fake livewallpaperspicker.apk in the C root directory)

Start> Run. Enter cmd and press Enter.
Apktool D "C: \ livewallpaperspicker.apk" "C: \ livewallpaperspicker"
(Command line explanation: the output folder of the file to be decompiled by apktool D)

In this example, livewallpaperspicker.apk is decompiled and the output content is in the C: \ livewallpaperspicker folder.

Open the c: \ livewallpaperspicker folder and we will find some XML files and folders. In most cases, the language and image resources are stored in the res folder. This example is no exception.

Open the res folder, which can contain many folders. In most cases, language resources are stored in the values * folder. For example, values is used in the default language (mostly in English), values-de is used in German, and values-fr is used in French. Generally, we are concerned with values-ZH-RCN (Simplified Chinese) and values-ZH-RTW (Traditional Chinese ).

Open the values-ZH-RCN folder, which contains strings. xml. Open and check:
<? XML version = "1.0" encoding = "UTF-8"?>
<Resources>
<String name = "application_name"> live wallpaper selector </string>
<String name = "live_wallpaper_picker_title"> current wallpaper </string>
<String name = "live_wallpaper_preview_title"> current wallpaper preview </string>
<String name = "configure_wallpaper"> set... </string>
<String name = "wallpaper_instructions"> set wallpaper </string>
<String name = "live_wallpaper_empty"> the current wallpaper does not exist. </String>
<String name = "set_live_wallpaper"> set wallpaper </string>
<String name = "wallpaper_title_and_author"> % 1 $ s provider: % 2 $ S </string>
<String name = "live_wallpaper_loading"> loading current wallpaper... </String>
</Resources>

Well, that's it. Change "Current Wallpaper" to "dynamic wallpaper", and then check and modify the punctuation marks-use Chinese Punctuation Marks in Chinese content (we strongly urge you to pay attention to the Punctuation Problem. At present, there are too many Trojans.

This example is enough. For other complex APK files, we recommend that you check the content in the res folder, at least the content in the language folder you are concerned about.

After modification, you can re-package it. In the CMD command line, enter:
Apktool B "C: \ livewallpaperspicker"
(Command line explanation: the folder in which apktool B wants to package content)
You can. The generated APK is named out.apk in the C: \ livewallpaperspicker \ distfolder.

This out.apk does not have a signature, so it cannot be directly installed into the mobile phone. For more information about signing tools and methods, see article 43.

The APK obtained after the signature can be installed in the mobile phone.

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.