Decoding an Android apk

The Android package format (apk) is actually a zip with some resources and compiled java. Sometime you want to peek into the package for troubleshooting issues. Unzipping the apk will not give you the best result. You actually need a tool that will give you a readable result.

That tool is the wonderful APKTOOL.

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.

Current version of apktool is 2.2.2.

Decode an apk:

  • Prerequisite: Java 1.7 installed
  • Download apktool from apktool/downloads
  • Store the apktool jar in the same folder as the apk
  • Start a command line / terminal and navigate to this folder
  • Run the following command: java –jar apktool_<version>.jar d <name of apk>

Example:

java –jar apktool_2.2.2.jar d test-app.apk

This will create a new folder based on the name of the apk with its contents.
If desired you can now manipulate the contents of the folder(s).

 

Build a new apk from the contents:

  • Run the following command: java –jar apktool_<version>.jar b <name of folder containing contents apk>
  • A newly built apk will be located in <name of folder containing contents apk>/dist directory

Example:

java –jar apktool_2.2.2.jar b test-app

The example would generate an apk in test-app/dist called test-app.apk.

 

Notes:

Above instructions should work more or less similarly on Windows, Mac and Linux.
You can find the Apktool documentation here.