Decompile the apk file to obtain its source code.

Source: Internet
Author: User
Tags admob

1. decompile Apk to get the Java source code

Dex2jar and JD-GUI these two tools with learning android is too reliable, so put up to share with you, the advantages of open source is good things to share with you.

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
It is worth noting that the old version of the software does not support the latest android applications.
1. First find classes. dex in the Android installation package

Change the APK file name to .zip, and decompress the classes file. 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 windows:
In command line mode, locate the directory where dex2jar. bat is located and run dex2jar. bat classes. dex to generate classes. dex. dex2jar. jar.
In Ubuntu:
Locate the directory of dex2jar. sh in the terminal and run
Sh dex2jar. sh classes. dex
You can 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

========================================================== =
2. 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.
Steps:
1. decompress the two downloaded files. aapt.exe and apktool.bat.(copy A. jar file after extracting apktool-install-windows-2.20.r01-1.zipthe package)
2. Open the command window (Start> Run, Enter cmd, and press Enter .) Go to the apktool. bat folder.
Input:
Apktool d C: \ ***. apk C: \ *** folder
(Command line explanation: the output folder of the file to be decompiled by apktool d)
Note: files to be decompiled must be placed in the root directory of drive C,
3. Open the C: \ *** folder to get various resources of our school.

3. Repackage decompiled files into apk
It's easy to enter:
Apktood B c: *** folder (you compiled the folder)
(For more information, see the original article)

========================================================== ====================
The android-apktool software can access its homepage. 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"

Copy code
(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"

Copy code
(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 the signature tools and methods, see http://www.hiapk.com/bbs/thread-21261-1.html.

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

Practice: remove the advertisement bar of the free version of software

[Http://bbs.ophone8.net/viewthread.php? Tid = 18082]

Open google code and find that Apktool is updated. win is supported ....
This article is a note about using Apktool in windows.
Install

1. Install the JAVA environment first. JDK/JRE will do all the work. Skip the steps after downloading and installing it on the official website.

2.download apktool.jarand the relevant files. Here, apktool-1.0.0.tar.bz2 and apktool-install-windows-2.20.r01-1.zip

3. Decompress apktool. jar to C: \ Windows to decompress apktool-install-windows.zip to any folder (such as the root directory of the E disk)
4. Run CMD in Win + R, run the cd command to go to The apktool-install-windows folder, and enter apktool. And some help will be listed. Apktool command

Apktool d XXX.apk ABC deserialization XXX.apk to the folder ABC
Apktool B ABC re-creates the APK from the folder ABC and outputs it to ABC \ dist \ out.apk.
Then we decompile a piece of software to play...
There is an advertisement at the bottom of the free version of AutoMemoryManager. Remove it.
Put com.lim.android.automemman.apk in the same folder (My is the root directory of the E disk)
Win + R run CMD
E: <press enter>
E: \> apktool d com.lim.android.automemman.apk AMM <enter>
I: Baksmaling...
I: Decoding resource table...
I: Decoding resources...
I: Copying assets and libs...
Now the file has been decode to E: \ AMM. Open E: \ AMM \ res \ layout \ main. xml and you can see it all ~
Edit row 59th

<Com. admob. android. ads. adView android: id = "@ id/ad" android: layout_width = "fill_parent" android: layout_height = "wrap_content" admobsdk: backgroundColor = "# ff000000" admobsdk: textColor = "# ffffffff" admobsdk: keywords = "Android application"/>

Change

<Com. admob. android. ads. adView android: id = "@ id/ad" android: layout_width = "0.0dip" android: layout_height = "0.0dip" admobsdk: backgroundColor = "# ff000000" admobsdk: textColor = "# ffffffff" admobsdk: keywords = "Android application"/>

Then Enter CMD
E: \> apktool B AMM
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...
Use Auto-sign to sign E: \ AMM \ dist \ out.apk for Installation
In this way, the advertisement will disappear.

Look again, hey ~ Handsome...
This actually changes the ADmob ad ID in AndroidManifest. xml.

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.