Decompiling & Recompiling Android APKs

Leave a Comment

Decompiling & Recompiling Android APKs

(Decompiling & Recompiling Android APKs using APK Tool)

APK Tool Introduction.

A tool for reverse engineering 3rd party, closed, binary Android apps. It can decode resources to nearly original form and rebuild them after making some modifications. It also makes working with an app easier because of the project like file structure and automation of some repetitive tasks like building apk, etc.

Quick Checks.

1. Check if Java 1.7 is Installed.
2. Does executing java -version  on command line / command prompt return 1.7.
C:\Windows\system32>java -version
java version "1.7.0_111"
Java(TM) SE Runtime Environment (build 1.7.0_111-b14)
Java HotSpot(TM) Client VM (build 25.111-b14, mixed mode, sharing)
3. If not Install Java 7 and make it default.


  • Windows:
  1. Download Windows wrapper script (Right click, Save Link As  apktool.bat )
  2. Download apktool-2 (find newest here).
  3. Rename downloaded jar to  apktool.jar .
  4. Move both files ( apktool.jar  &  apktool.bat ) to your Windows directory (Usually  c://Windows ).
  5. If you do not have access to  c://Windows , you may place the two files anywhere then add that directory to your Environment Variables System PATH variable.
  6. Try running  apktool  via command prompt.

Step 1: Finding Framework Files.

There are two types of framework files, which should be extracted from your Android device. These files can be found in the root of your android device. (Note: Framework files are in .apk format).
These files are usually named as "resource" ,"res" or "framework" .


Step 2: Installing Framework Files.

  1. Make a new folder.
  2. Paste the two framework files (That you grabbed from your android device).
  3. Paste the apk which you desire to edit, in that particular folder.
     4. [Shift] + [Right Click]. In that folder location. Then choose "Open command window here".
     5. Type the following commands.

E:\Test>apktool if framework-res.apk
I: Framework installed to: 1.apk 

E:\Test>apktool if twframework-res.apk
I: Framework installed to: 2.apk 

Step 3: Decompiling APK .

1. After installing the framework files its the time to decompile the apk.
2. Use the following command to decompile the apk.
E:\Test>apktool d ABCHHackerz.apk
I: Using Apktool 2.2.1 on ABCHHackerz.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Home\AppData\Local\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
3. The files from the apk are been extracted in the folder. Replacements, Script Editing, Other changes can be done in there.

Step 3: Re-Compiling APK .

1. When all the needed changes are been finished. Its the time to Re-Compile the extracted folder.
E:\Test>apktool b ABCHHackerz
I: Using Apktool 2.2.1 on ABCHHackerz
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...
I: Copying unknown files/dir...
2. After the building process completes. The compiled apk is stored in the Extracted folder.
ABCHHackerz(Extraxted Folder)\dist\ABCHHackerz.apk(Compiled APK)

3. The Compiled APK is currently Unsigned. So you can't install it yet. You have to sign it for installing it on your device.

Step 3: Signing APK .

1. For Signing an apk you'll need APK Editor Pro (Download).
2. Install APK Editor Pro on you Android Device.
3. Further Instructions are in the following Video.

References .

Credits to iBotPeaches for creating such an awseome tool.


Post a Comment