[GUIDE][HOW-TO] Decompile and Compile apps using Apktool in 5 Simple Steps

pixerx21

Member
Aug 16, 2016
5
1
0
Hello :)

I want to keep things simple and very easy. I will write a 5 step guide for setting up apktool and start modifying your app's or any other android framework. This guide will be strictly for windows users, since setting up and using apktool in windows is the easiest.
So lets begin -



What you need before you learn how to use apktool -

  1. A computer running windows
  2. A working internet connection for downloading the following -
    • JAVA SDK and JRE
    • Android SDK
    • Apktool core tool
    • Sign apk tool
  3. Basic command prompt commands and path knowledge
  4. A good linux format code editing program like NotePad ++ [Get it from HERE]


STEP 1 - Install JAVA - Go HERE



  • Just go to the above website and download java SDK and JRE.
  • We mostly use only SDK libraries but JRE is required when you want to modify games or apps like whatsapp. So its best if we install both.
  • install them in any directory for example C:\ drive and you are good to go to next step 2.

STEP 2 - Install Android SDK- Go HERE



  • Just go to the above website and download the SDK.
  • Install it in an easy path. For example - C:\android
  • The short path will be useful when you are using adb for logcat purposes, since typing in a long path every-time you want to access the adb executable file is painful.
  • So once you installed the SDK move on to next step 3

STEP 3 - Download Apktool - Go HERE



  • For downloading apktool related files, you need to go HERE
  • Download latest apktool version, currenlty 1.5.2
  • Download the batch file and aapt.exe
  • Create a folder anywhere in the pc and put all the apktool.jar, aapt.exe and the batch script in that folder. [see screenshot]
  • This will be the operating folder for you now.
  • Next move to next step 4

STEP 4 - Using apktool for decompiling anything



  • Open command prompt
  • navigate to the folder where you placed apktool.jar, batch script and the aapt.exe [see screenshot]
  • For this guide i am using a simple framework-res.apk for reference.
  • Once you are in the folder via cmd prompt, you need to install the file using the " IF " command
  • type the following command -

    Code:
    [B]apktool if [I]name-of-the-app[/I] .apk[/B]
    For example, once the command is executed correctly, it will look like this -

    Code:
    [B]apktool if framework-res.apk[/B]
  • Once the app is installed you need to decompile it.
  • For decompiling use the command "d". The "d" stands for decompile.

    Code:
    [B]apktool d [I]name-of-the-app[/I] .apk[/B]
    For example -

    Code:
    [B]apktool d [I]framework-res.apk[/I][/B]
  • After the app is correctly decompiled, a new folder will be created in the same folder where you placed your app. This contains all the xml's and smali files which can be edited for different mod's.

    For example, here's how it will look once the app is decompiled -

  • Then after you are finished with your modding, you need to recompile your app for using it.
  • To recompile the app use the following command " B ". The "b" simply means recompile.

    Code:
    [B]apktool b [I]name-of-the-app-folder[/I][/B]
  • NOTE - While recompiling the app, you just need to type the name of the folder the app's files contains.
    For example -

    Code:
    [B]apktool b [I]framework-res[/I][/B]
    framework-res is the name of the folder

  • The final modded app will be in the dist folder located inside the original app folder created by apktool.

    For example -

  • Congrats ! If everything went well, you successfully created a modified app ! :)
  • Now the most important step is below in step 5





STEP 5 - Signing the apk

  • to sign an apk download the "sign-apk.rar" from below attachements
  • extract it to any place.
  • open a new command prompt and change into the sign-apk directory using cmd
  • move the modified-unsigned apk into this folder [see screenshot] -
  • then type the following command -

    Code:
    [B]java -jar signapk.jar certificate.pem key.pk8 [I]path-of-the-folder-contaning-the-apk .apk path-of-the-new-signed-apk .apk[/I][/B]
    For example -


    Code:
    [B]java -jar signapk.jar certificate.pem key.pk8 [I]framework-res.apk framework-res-signed.apk[/I][/B]
  • Once compiled, the signed apk will be found in the same folder.
  • This is FINAL APK. :)
  • Simply rename it to the original apk and push it into the system ! DONE ! :D


If you have any errors or problems related to apktool, post them here, I will try to solve them. :)
I got "error: Unable to access jarfile C:\Apktools\\apktool.jar
 

lesterocks

New member
Nov 12, 2016
1
0
0
Hello sir.

I was trying to decompile an apk. I followed your instruction. Then i got this error.

C:\other mod>apktool if framework-res.apk
Exception in thread "main" brut.androlib.AndrolibException: java.io.FileNotFound
Exception: framework-res.apk (The system cannot find the file specified)
at brut.androlib.res.AndrolibResources.installFramework(AndrolibResource
s.java:584)
at brut.androlib.Androlib.installFramework(Androlib.java:473)
at brut.apktool.Main.cmdInstallFramework(Main.java:250)
at brut.apktool.Main.main(Main.java:81)
Caused by: java.io.FileNotFoundException: framework-res.apk (The system cannot f
ind the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at brut.androlib.res.AndrolibResources.installFramework(AndrolibResource
s.java:552)
... 3 more


Please help me. Thanks in advance.
 

kevintm78

Senior Member
May 28, 2013
1,278
2,465
153
Bluegrass State
I was trying to decompile an apk. I followed your instruction. Then i got this error.

C:\other mod>apktool if framework-res.apk
Exception in thread "main" brut.androlib.AndrolibException: java.io.FileNotFound
Exception: framework-res.apk (The system cannot find the file specified)
at brut.androlib.res.AndrolibResources.installFramework(AndrolibResource
s.java:584)
at brut.androlib.Androlib.installFramework(Androlib.java:473)
at brut.apktool.Main.cmdInstallFramework(Main.java:250)
at brut.apktool.Main.main(Main.java:81)
Caused by: java.io.FileNotFoundException: framework-res.apk (The system cannot f
ind the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at brut.androlib.res.AndrolibResources.installFramework(AndrolibResource
s.java:552)
... 3 more


Please help me. Thanks in advance.
Not sure if you still need the help, but did you make sure to have the framework file in the same folder as the apktool.jar file.
 

misa2610

New member
Dec 14, 2016
1
0
0
Already 4 day's trying to compile and sign my apk but i am getting frustrated now. I can't compile it again, is there some who wants to compile and sign my apk pleasssseee
 

Shakti_Bug

New member
Dec 29, 2016
1
0
0
Error in Signing the APK

Usage: signapk publickey.x509[.pem] privatekey.pk8 input.jar output.jar
I'm having this problem when signing the apk. How Do I solve this? Thanks in advance.
 

csanuragjain

New member
Apr 1, 2017
2
0
0
[Tool] Automating Decompilng & Recompilng of APK

Hi,
Since decompilation, modification and recompilation of apk required several tools so I created a java GUI tool APKRepatcher which helps you to modify an existing apk using a simple user friendly GUI. It lets you edit java/smali code from an APK and rewrite the changes back to the modified signed APK. Additionally, it provides you option to convert Dex, Jar, Class, Smali, Class from one format to another.

github.com/csanuragjain/apkRepatcher

Thanks
 

villedas

Member
Jun 19, 2015
45
21
0
Reynosa
Great tutorial step by step...

Hey man! I followed all the steps, and Thank you so much, for all the explanations, I modified my first applications with these tutorial.

Thank you! :victory:

Regards! :highfive:
 

ajaikumarnadar

Senior Member
Sep 9, 2016
231
57
28
24
MUMBAI
Hello :)

I want to keep things simple and very easy. I will write a 5 step guide for setting up apktool and start modifying your app's or any other android framework. This guide will be strictly for windows users, since setting up and using apktool in windows is the easiest.
So lets begin -



What you need before you learn how to use apktool -

  1. A computer running windows
  2. A working internet connection for downloading the following -
    • JAVA SDK and JRE
    • Android SDK
    • Apktool core tool
    • Sign apk tool
  3. Basic command prompt commands and path knowledge
  4. A good linux format code editing program like NotePad ++ [Get it from HERE]


STEP 1 - Install JAVA - Go HERE



  • Just go to the above website and download java SDK and JRE.
  • We mostly use only SDK libraries but JRE is required when you want to modify games or apps like whatsapp. So its best if we install both.
  • install them in any directory for example C:\ drive and you are good to go to next step 2.

STEP 2 - Install Android SDK- Go HERE



  • Just go to the above website and download the SDK.
  • Install it in an easy path. For example - C:\android
  • The short path will be useful when you are using adb for logcat purposes, since typing in a long path every-time you want to access the adb executable file is painful.
  • So once you installed the SDK move on to next step 3

STEP 3 - Download Apktool - Go HERE



  • For downloading apktool related files, you need to go HERE
  • Download latest apktool version, currenlty 1.5.2
  • Download the batch file and aapt.exe
  • Create a folder anywhere in the pc and put all the apktool.jar, aapt.exe and the batch script in that folder. [see screenshot]
  • This will be the operating folder for you now.
  • Next move to next step 4

STEP 4 - Using apktool for decompiling anything



  • Open command prompt
  • navigate to the folder where you placed apktool.jar, batch script and the aapt.exe [see screenshot]
  • For this guide i am using a simple framework-res.apk for reference.
  • Once you are in the folder via cmd prompt, you need to install the file using the " IF " command
  • type the following command -

    Code:
    [B]apktool if [I]name-of-the-app[/I] .apk[/B]
    For example, once the command is executed correctly, it will look like this -

    Code:
    [B]apktool if framework-res.apk[/B]
  • Once the app is installed you need to decompile it.
  • For decompiling use the command "d". The "d" stands for decompile.

    Code:
    [B]apktool d [I]name-of-the-app[/I] .apk[/B]
    For example -

    Code:
    [B]apktool d [I]framework-res.apk[/I][/B]
  • After the app is correctly decompiled, a new folder will be created in the same folder where you placed your app. This contains all the xml's and smali files which can be edited for different mod's.

    For example, here's how it will look once the app is decompiled -

  • Then after you are finished with your modding, you need to recompile your app for using it.
  • To recompile the app use the following command " B ". The "b" simply means recompile.

    Code:
    [B]apktool b [I]name-of-the-app-folder[/I][/B]
  • NOTE - While recompiling the app, you just need to type the name of the folder the app's files contains.
    For example -

    Code:
    [B]apktool b [I]framework-res[/I][/B]
    framework-res is the name of the folder

  • The final modded app will be in the dist folder located inside the original app folder created by apktool.

    For example -

  • Congrats ! If everything went well, you successfully created a modified app ! :)
  • Now the most important step is below in step 5





STEP 5 - Signing the apk

  • to sign an apk download the "sign-apk.rar" from below attachements
  • extract it to any place.
  • open a new command prompt and change into the sign-apk directory using cmd
  • move the modified-unsigned apk into this folder [see screenshot] -
  • then type the following command -

    Code:
    [B]java -jar signapk.jar certificate.pem key.pk8 [I]path-of-the-folder-contaning-the-apk .apk path-of-the-new-signed-apk .apk[/I][/B]
    For example -


    Code:
    [B]java -jar signapk.jar certificate.pem key.pk8 [I]framework-res.apk framework-res-signed.apk[/I][/B]
  • Once compiled, the signed apk will be found in the same folder.
  • This is FINAL APK. :)
  • Simply rename it to the original apk and push it into the system ! DONE ! :D


If you have any errors or problems related to apktool, post them here, I will try to solve them. :)



i tried it with mi pop apk since i couldnt install it.. but
i am sure that i followed your steps.. correctly.. since i double checked each and every step.. by i couldnt do this mi pop. apk. can somebody help.. :confused:
 

_D0MINIK_

New member
Nov 5, 2016
1
0
0
HELP!

Help me please! Im getting this error:
PHP:
I: Using Apktool 2.2.4
W: Could not find sources
[Fatal Error] :18:9: Element type "application" must be followed by either attribute specifications, ">" or "/>".
I: Checking whether resources has changed...
I: Building resources...
W: /home/dominik/apktool/BomberCousins/AndroidManifest.xml:18: error: Error parsing XML: not well-formed (invalid token)
W: 
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_271441253519481805.tmp, p, --forced-package-id, 127, --min-sdk-version, 10, --target-sdk-version, 21, --version-code, 200, --version-name, 1.59, --no-version-vectors, -F, /tmp/APKTOOL816358900983601581.tmp, -0, arsc, -0, txt, -0, arsc, -I, /home/dominik/.local/share/apktool/framework/1.apk, -S, /home/dominik/apktool/BomberCousins/res, -M, /home/dominik/apktool/BomberCousins/AndroidManifest.xml]
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:496)
	at brut.androlib.Androlib.buildResources(Androlib.java:430)
	at brut.androlib.Androlib.build(Androlib.java:329)
	at brut.androlib.Androlib.build(Androlib.java:267)
	at brut.apktool.Main.cmdBuild(Main.java:230)
	at brut.apktool.Main.main(Main.java:83)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_271441253519481805.tmp, p, --forced-package-id, 127, --min-sdk-version, 10, --target-sdk-version, 21, --version-code, 200, --version-name, 1.59, --no-version-vectors, -F, /tmp/APKTOOL816358900983601581.tmp, -0, arsc, -0, txt, -0, arsc, -I, /home/dominik/.local/share/apktool/framework/1.apk, -S, /home/dominik/apktool/BomberCousins/res, -M, /home/dominik/apktool/BomberCousins/AndroidManifest.xml]
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:441)
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:482)
	... 5 more
Caused by: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_271441253519481805.tmp, p, --forced-package-id, 127, --min-sdk-version, 10, --target-sdk-version, 21, --version-code, 200, --version-name, 1.59, --no-version-vectors, -F, /tmp/APKTOOL816358900983601581.tmp, -0, arsc, -0, txt, -0, arsc, -I, /home/dominik/.local/share/apktool/framework/1.apk, -S, /home/dominik/apktool/BomberCousins/res, -M, /home/dominik/apktool/BomberCousins/AndroidManifest.xml]
	at brut.util.OS.exec(OS.java:95)
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:435)
	... 6 more
If you need any files tell me, thanks for help!
 

Davolex1

Senior Member
Nov 23, 2017
52
2
0
Hi good work in here too .pls i want to change the mah of my battery from 3200mah to 10000mah..


Pls how do i make it work with this method?
 

Eures

Senior Member
Sep 2, 2012
50
3
0
APKTOOL RELATED FILES (apktool.bat and aapt.exe)

Hello people,

in STEP 3 he says: "For downloading apktool related files, you need to go to https://code.google.com/p/android-apktool/downloads/list"

We go there and we see that the link has moved to http://ibotpeaches.github.io/Apktool/

Ok, now we see the latest version of Apktool to download, but the apktool related files, i. e. apktool.bat and aapt.exe, are a bit difficult to see, they are located under:

23 Dec 2012 - Scripts r05-ibot Released
Mac, Windows, Linux

I hope it can help.
 
Last edited:

l178628

Member
Jun 13, 2017
12
1
0
Hello people,

in STEP 3 he says: "For downloading apktool related files, you need to go to https://code.google.com/p/android-apktool/downloads/list"

We go there and we see that the link has moved to http://ibotpeaches.github.io/Apktool/

Ok, now we see the latest version of Apktool to download, but the apktool related files, i. e. apktool.bat and aapt.exe, are a bit difficult to see, they are located under:

23 Dec 2012 - Scripts r05-ibot Released
Mac, Windows, Linux

I hope it can help.
thank you
 

americo silva

New member
Mar 18, 2015
4
0
21
ownice c500+

You really rock! You wrote a while awesome thread just cause one Guy mentioned he couldn't get it up and running and he didn't even ask for help.... you are awesome..,

Sent from my GT-S5570 using Tapatalk 2
soft brick fixer ownice c500+

---------- Post added at 05:35 PM ---------- Previous post was at 05:33 PM ----------

soft brick fixer ownice c500+
soft brick fixer ownice c500+
 
Dec 24, 2017
35
1
8
Delhi
Hi
Can anyone edit an APK for me? You have to just change the target SDK version to 28 to support it for Android pie.

APK name : MiPicks(now called GetApps)

When I decompile the APK I get no errors

After when I change the target SDK version from AndroidManifest.xml or apktool.yml file

When I recompile it I get error messages like
Can't find attr for compilesdkversion
Or like brut....can't exec ......

Please help me.