Today I am writing about a very basic process in the Android Community, i.e. Decompiling & Recompiling Android apps using the infamous Apktool software. I will cover all the steps like downloadng,installation , usage & minor troubleshooting.
What the heck is this thing & Why should I do it?
Android apps as you get them are standard “apk” files like angry_birds.apk . Now if you have been playing around XDA website , you must have come across minor or major guides of modding your status bar/launcher/home page or even commonly available apps. Such modding/theming steps cannot be done on the apk file directly. You need to be able to play with the source code of an app in order to go around with much of the editing process.At this point, apktool comes into picture. It’s a simple tool which takes up a apk file and decompiles (=converts apk back to its source code) the app. Later after required edits , it also has the capability to recompile(=builds apk file from source code) the apps.
Where to get this awesome tool ?
This tool is currently maintained by xda member ibotpeaches who constantly updates it and provides new versions with required patches(bug-fixes).
Head over to here ,Scroll down to below and download the latest apktool version from there.It would look something like the picture below.
Now all you need is a computer running windows and a usable mind !!!
- Download the latest apktool version from above given link and rename it to apktool.jar
- Now download this zip file from here.It contains the other resources for apktool installation.
- Create a new folder and give it any name like ” Apktool “. Put the apktool.jar file here.
- Extract the files from downloaded zip and move them along with the apktool.jar in the new folder so that it looks like the image below.
Installation Complete !
Part – 1 Installing Framework (Needs to be done once . To be redone only if you are working with files from other device)
Before you can start with decompiling apk files , you need some files from your phone so that apktool can function properly.
The following files are needed
|SystemUI.apk (optional)||>||/system/app or /system/priv-app|
Now for some manufacturers (Sony, Samsung , HTC etc) you need their specific files . For eg. for Samsung you need the twframework-res.apk file too. The best way of doing this is to copy any other apk files in the /system/framework folder and keep them along with the above files.
In order to get these files from the phone , you can either use a file manager like ES File Explorer or you can use ADB.If you don’t know what ADB is, I will cover it in one of my tutorials.
- After you get these files keep them in the folder you made .
- Now in that folder, hold down shift key and click Right-Mouse button.You will get a menu like the picture below.
- Click on “Open command window here” and you will get a command prompt screen.
- Now type the following :
apktool if framework-res.apk
and press enter.(if= install framework)
- Similarly keep typing this for each file you copied from your phone (framework.jar etc) and each time keep replacing framework-res.apk with the name of the file.
- After this you are done with part-1 and you can delete the files you copied from device from the apktool folder.
Part – 2 Decompiling
This process is pretty easy.
- Copy paste the apk file you wish to decompile in the apktool folder.
- Now type in
apktool d filename.apk
- And tadaa , you will get the decompiled apk files in the folder named “filename”
- Similarly, you can decompile almost every apk file.
Part – 3 Recompiling
- Now you have made changes and you wish to build the apk back.
- Suppose that the decompiled files exist in the folder named “filename”
- Then type
apktool b filename
(b= build the apk)
- This will build the apk and name it file.apk located in filename/dist folder.
Part – 4 Signing the APK
Android has a certain security feature which requires the app to be digitally signed in order to be installed.Without this you will see “App not installed” error message while installing the app.
- To sign a app named file.apk use this command,
java -jar signapk.jar certificate.pem key.pk8 file.apk file-signed.apk ( can be whatever name you give to your apk )
This will create a new apk called file-signed.apk which is ready to be installed to a device.
Now you are free to use apktool to mod/theme apps in the way you want.For any questions just comment below.
Have a Good Day !
Liked This Post ?
Think how much you can learn with more such posts..Get updated in your inbox right away.
Thank you for subscribing.
Something went wrong.