Monday, January 20, 2014

Android Tutorial | How to Decompile - Recompile and Sign APKs

Decompile - Recompile and Sign APKs

This is another Tutorial for Editing and Modifying APKs using apktool and signapk. Also it's easy just follow the instructions carefully.

Why do I have to decompile apk?

Android apps(apk) are basically made up of Java codes and XML files. After compiling the app, these files cannot be viewed. Decompiling is a process which decompiles the binary form of XMLs and .java files into readable form. The XML files can be retained as it is, but the .java files are converted into smali files, a totally different language.

What is recompiling?

Recompiling is simply a way to convert the XML and smali files back into the binary form and building up of the APK with the changes made. All apps after recompiled have to be signed (except system apps).


Things you will need:

  1. PC
  2. APK/s that you want to decompile, edit, recompile and sign
  3. Java JDK( Java Development Kit ) and JRE (Java Runtime Environment)
  4. Apktool
  5. SignApk
  6. Framework-res.apk located in /system/framework of your base rom
  7. SystemUI located in /system/app of your base rom

Decompiling APKs

steps:
  1. Install Java JRE and JDK, after installing reboot your PC.
  2. Place Apktool, framework-res.apk and systemui.apk and the apk you want to modify in a folder in the root of your drive C. Name it as apktool.
  3. Inside the folder, press 'Shift' and right-click on an empty space, and select "open command window here"
  4. Install first framework-res.apk and systemUI.apk by typing in the following command:  apktool if (framework's folder/location)
 example: apktool if C:\apktool\framework-res.apk
Decompile - Recompile and Sign APKs
 Do this also for systemUI.apk
NOTE: You can not always install the framwork-res.apk and changing systemui.apk, unless if you change your rom. But to Prevent errors you may also installed.

Inside the command window, type the following, and press enter:  java -jar apktool.jar d your-app.apk destination folder

example: java -jar apktool.jar d ucbrowser.apk decompiled_ucbrowser
Decompile - Recompile and Sign APKs
  1. You should see a couple of things appearing in the command window, just wait for the process to finish
  2. When it is finished, close the command window
  3. Inside the folder where you extracted all the files and ran these commands, a new folder should have formed, with the name of the APK you decompiled ( decompiled_ucbrowser )
  4. Inside the folder, are all the contents of the APK. You may now proceed in editing the apk.
After editing the apk, you will need to recompile it.

Recompiling APKs

steps:
  1. Open a command window using the same method as step #3.
  2. Inside the command window, type the following, and press enter: apktool b folder apk_name.apk
example: apktool b decompiled_ucbrowser ucbrowser.apk
Decompile - Recompile and Sign APKs

Signing APKs

steps:
  1. Create a folder in drive C and name it as signapk and extract the contents of the downloaded SignApk (signapk.jar, key.pk8, certificate.pem) to this folder.
  2. Inside the folder, press 'Shift' and right-click on an empty space, and select 'open command window here.
  3. Inside the command window, type the following, and press enter: java -jar signapk.jar certificate.pem key.pk8 your-app.apk your-app-signed.apk
example java -jar signapk.jar certificate.pem key.pk8 C:\Signapk\ucbrowser.apk C:\Signapk\ucbrowser-signed.apk
Decompile - Recompile and Sign APKs

Done. Happy editing

You may also try this https://code.google.com/p/easy-apk-dissassembler/



Credits to XDA for this Tutorial
Related Posts with Thumbnails

3 comments:

  1. Great tutorial! But please update link to apktool: https://bitbucket.org/iBotPeaches/apktool/downloads
    Mentioning Easy APK would also be nice: http://www.softpedia.com/get/Programming/Debuggers-Decompilers-Dissasemblers/Easy-Apk-Dissassembler.shtml

    ReplyDelete
  2. Sorry, wrong link: https://code.google.com/p/easy-apk-dissassembler/

    ReplyDelete