Skip to main content

Introduction

First lets take a lesson into apk files. Apks are nothing more than a zip file containing resources and assembled java code. If you were to simply unzip an apk like so, you would be left with files such as classes.dex and resources.arsc.

$ unzip testapp.apk
Archive: testapp.apk
inflating: AndroidManifest.xml
inflating: classes.dex
extracting: res/drawable-hdpi/ic_launcher.png
inflating: res/xml/literals.xml
inflating: res/xml/references.xml
extracting: resources.arsc

However, at this point you have simply inflated compiled sources. If you tried to view AndroidManifest.xml. You'd be left viewing this.

�����������P��������������4���F���������������������0��\��f��n���v�e�r�s�i�o�n�C�o�d�e����v�e�r�s�i�o�n�N�a�m�e����a�n�d�r�o�i�d���*�h�t�t�p�:�/�/�s�c�h�e�m�a�s�.�a�n�d�r�o�i�d�.�c�o�m�/�a�p�k�/�r�e�s�/�a�n�d�r�o�i�d��������p�a�c�k�a�g�e����p�l�a�t�f�o�r�m�B�u�i�l�d�V�e�r�s�i�o�n�C�o�d�e����p�l�a�t�f�o�r�m�B�u�i�l�d�V�e�r�s�i�o�n�N�a�m�e����m�a�n�i�f�e�s�t����b�r�u�t�.�a�p�k�t�o�o�l�.�t�e�s�t�a�p�p����1�.�0����2�1����A�P�K�T�O�O�L����������������������������������������������������������������������������

Obviously, editing or viewing a compiled file is next to impossible. That is where Apktool comes into play.

$ apktool d testapp.apk
I: Using Apktool 2.0.0 on testapp.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: 1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...

Viewing AndroidManifest.xml again results in something much more human readable

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="https://schemas.android.com/apk/res/android" package="brut.apktool.testapp"
platformBuildVersionCode="21" platformBuildVersionName="APKTOOL" />

In addition to XMLs, resources such as 9 patch images, layouts, strings, and much more are correctly decoded to source form.