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

Search This thread

A_U

Senior Member
Jun 6, 2012
3,330
4,588
Wichita
www.facebook.com
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

attachment.php


  • 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

attachment.php


  • 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

attachment.php


  • 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

attachment.php


  • 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 -
    attachment.php

    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 -
    attachment.php

  • 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 -
    attachment.php

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


NOTE - You MUST follow the step 5. Or else the app wont work and when you try to push it into system, the rom will be stuck in bootloop XD


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] -
    attachment.php
  • 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 -
    attachment.php


    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.
    attachment.php
  • 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. :)
 

Attachments

  • SignApk.zip
    9.2 KB · Views: 73,812

A_U

Senior Member
Jun 6, 2012
3,330
4,588
Wichita
www.facebook.com
apple.jpg


STEP 1 : Rooting MAC

If you have a mac, apk manager doesn't work on macs. So, you must use apktool. To set up apktool, you must have root mode enabled on your mac. To do that, simply follow these steps:
  • Open system preferences
  • Open accounts
  • Go to login options
  • Hit join next to network account server
  • Select open directory utility
  • Click the lock at the bottom of the window that pops up and enter an admin password
  • Then, go to the top bar on your mac, hit edit, and select enable root mode


STEP 2 : SETTING UP APKTOOL

Once you have root mode enabled, you're ready to set up apktool :
  • From the apktool website, download apktool-latest-version.tar.bz2 and apktool-install-macosx-latest-version.tar.bz2
  • Next, open terminal type :

    Code:
    [B]su
    tar -C /usr/local/bin -xvf <zipped file name>
    tar -C /usr/local/bin -xvf <zipped file name> (for the second file)[/B]
  • Now to confirm it worked, type "apktool" no quotes
  • You should get a help menu for apktool
  • If you got it, you're good to go to next step.


STEP 3 : USING APKTOOL

Now, once you have it set up, you're ready to go! After typing apktool, you'll see the help menu which'll give you the commands available for apktool, but I'll go over the basic ones here.
  • For installing frameworks or apps
    Code:
    apktool if
  • This command will decompile the apk
    Code:
    apktool d "apk path here"
  • This command will build an apk from a previously decompiled one
    Code:
    apktool b "decompiled apk path here"

----------------------------------------------------------

linux_logo.jpg


Screenshot%20from%202012-08-19%2022:04:45.png


Download the apktool.java file along with other files, as shown above. Extract them to the desktop.

Now open terminal and type line by line :

Note : "android" in all the below commands is my username. So it changes according to your pc name ;)

We are giving root permissions for the 3 files that you extracted above.
Code:
chown -R android:android '/home/android/Desktop/apktool.jar'
press enter

Code:
chown -R android:android '/home/android/Desktop/aapt'
press enter

Code:
chown -R android:android '/home/android/Desktop/apktool'
press enter


Next make all 3 files executable by doing the same thing one at a time pressing enter in between each one:
Code:
sudo chmod +x '/home/android/Desktop/apktool.jar'
after the first it will ask you for your password type it, you shouldnt need it after that for the rest

Code:
sudo chmod +x '/home/android/Desktop/aapt'
Code:
sudo chmod +x '/home/android/Desktop/apktool'
now we need to move all three files to bin folder to do it type this command and enter your password:
Code:
gksudo nautilus
a new window should pop up on the left click on "filesystem/usr/local/bin, then drag all three folders into the bin folder and close it.

APKTOOL is now ready and make your modifications on a linux distro easily :)
 
Last edited:

dzeig

Senior Member
Jan 7, 2013
310
73
for decompiling - compiling apk, use apk multi tool, waaay simpler. (and stable).
 
  • Like
Reactions: ToXiC

gabrielking9

Senior Member
Feb 12, 2012
2,331
410
Recife
Any tuto for Mac? :s Dunno how to access use folder to put the apktool in mac

Sent from my GT-S5570 using xda app-developers app
 

gabrielking9

Senior Member
Feb 12, 2012
2,331
410
Recife
Big thanks to this Guy named Alchemist will try install windows here and try It

Sent from my GT-S5570 using xda app-developers app
 

gabrielking9

Senior Member
Feb 12, 2012
2,331
410
Recife
Hey i am stuck at the part
" tar -C /usr/local/bin -xvf <zipped file name> "
What i need to do? I have the "apktool-install-macosx-r05-ibot.tar.bz2" file and the folder "apktool-install-macosx-r05-ibot" which one should i put in it? and i need put it with directory For example: /user/gabriel/desktop/apktool-install-macosx-r05-ibot ??? and i need put this "><" ??????
 
Last edited:

A_U

Senior Member
Jun 6, 2012
3,330
4,588
Wichita
www.facebook.com
i think the u need to put the contents of that tar file in bin folder and not the zip..
and could u unquote my post ? :p its a bit annoying to scroll down..
 

A_U

Senior Member
Jun 6, 2012
3,330
4,588
Wichita
www.facebook.com
1st try with <> if it doesnt work, just remove and execute..
sorry i am not able to remember bcoz i just checked my frnds laptop at the office when he was working...so i had to hurry things up..
 

Top Liked Posts

  • There are no posts matching your filters.
  • 171
    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

    attachment.php


    • 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

    attachment.php


    • 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

    attachment.php


    • 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

    attachment.php


    • 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 -
      attachment.php

      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 -
      attachment.php

    • 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 -
      attachment.php

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


    NOTE - You MUST follow the step 5. Or else the app wont work and when you try to push it into system, the rom will be stuck in bootloop XD


    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] -
      attachment.php
    • 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 -
      attachment.php


      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.
      attachment.php
    • 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. :)
    15
    apple.jpg


    STEP 1 : Rooting MAC

    If you have a mac, apk manager doesn't work on macs. So, you must use apktool. To set up apktool, you must have root mode enabled on your mac. To do that, simply follow these steps:
    • Open system preferences
    • Open accounts
    • Go to login options
    • Hit join next to network account server
    • Select open directory utility
    • Click the lock at the bottom of the window that pops up and enter an admin password
    • Then, go to the top bar on your mac, hit edit, and select enable root mode


    STEP 2 : SETTING UP APKTOOL

    Once you have root mode enabled, you're ready to set up apktool :
    • From the apktool website, download apktool-latest-version.tar.bz2 and apktool-install-macosx-latest-version.tar.bz2
    • Next, open terminal type :

      Code:
      [B]su
      tar -C /usr/local/bin -xvf <zipped file name>
      tar -C /usr/local/bin -xvf <zipped file name> (for the second file)[/B]
    • Now to confirm it worked, type "apktool" no quotes
    • You should get a help menu for apktool
    • If you got it, you're good to go to next step.


    STEP 3 : USING APKTOOL

    Now, once you have it set up, you're ready to go! After typing apktool, you'll see the help menu which'll give you the commands available for apktool, but I'll go over the basic ones here.
    • For installing frameworks or apps
      Code:
      apktool if
    • This command will decompile the apk
      Code:
      apktool d "apk path here"
    • This command will build an apk from a previously decompiled one
      Code:
      apktool b "decompiled apk path here"

    ----------------------------------------------------------

    linux_logo.jpg


    Screenshot%20from%202012-08-19%2022:04:45.png


    Download the apktool.java file along with other files, as shown above. Extract them to the desktop.

    Now open terminal and type line by line :

    Note : "android" in all the below commands is my username. So it changes according to your pc name ;)

    We are giving root permissions for the 3 files that you extracted above.
    Code:
    chown -R android:android '/home/android/Desktop/apktool.jar'
    press enter

    Code:
    chown -R android:android '/home/android/Desktop/aapt'
    press enter

    Code:
    chown -R android:android '/home/android/Desktop/apktool'
    press enter


    Next make all 3 files executable by doing the same thing one at a time pressing enter in between each one:
    Code:
    sudo chmod +x '/home/android/Desktop/apktool.jar'
    after the first it will ask you for your password type it, you shouldnt need it after that for the rest

    Code:
    sudo chmod +x '/home/android/Desktop/aapt'
    Code:
    sudo chmod +x '/home/android/Desktop/apktool'
    now we need to move all three files to bin folder to do it type this command and enter your password:
    Code:
    gksudo nautilus
    a new window should pop up on the left click on "filesystem/usr/local/bin, then drag all three folders into the bin folder and close it.

    APKTOOL is now ready and make your modifications on a linux distro easily :)
    4
    noob question...
    pls tell me where to put baksmali.jar, smali.jar, baksmali.file, smali.file ?
    and how to use
    thanx

    Okay, first thing first, you'll need all of the above mention file, the appt.exe
    & apktool.bat is in a bz2 file [like zip] download it from the apktool website
    here http://ibotpeaches.github.io/Apktool/ & scroll down, you'll see below
    NEWS [23 Dec 2012 - Scripts r05-ibot Released] download it depending on
    your PC Windows,Mac, etc. & extract. Then download the latest apktool that
    is apktool 2.0 here https://bitbucket.org/iBotPeaches/apktool/downloads &
    rename it to [apktool.jar] After that, download all baksmali & smali V2.03
    here https://code.google.com/p/smali/downloads/list [I know baksmali &
    smali has been updated, but V2.0.3 is working flawlessly] Lastly, put all of the files
    into any folder you want or I would recommend to create a new folder named
    [apktool] in C:/Windows/HERE [apktool] after that run it by the apktool.bat
    or press [Shift + Right Click] then you'll see option "open command window here"
    Then check your current version by typing in CMD
    Code:
    apktool -version
    If it show " apktool 2.0.0" in CMD, then you've successfully installed :good:
    To use it for compiling, first put framework-res of your ROM in the apktool folder
    I've mention, then put any apk you want to compile [example, SystemUI.apk]
    First, to prepare the compiling type in CMD
    Code:
    apktool if framework-res.apk
    Then, type
    Code:
    apktool if SystemUI.apk
    After that, type
    Code:
    apktool d SystemUI.apk
    Lastly, after done editing & stuff, recompile by typing in CMD
    Code:
    apktool b SystemUI
    [for recompiling, you do not need to type the ".apk" at the end of apk name, just
    simply type the apk name]
    NOTE: You don't have to do the, "apktool if SystemUI.apk" command for other APK
    Just do the "apktool if framework-res.apk" at the beginning & you're good to go :cowboy:
    Hit the thanks button if I helped :fingers-crossed:
    2
    will write that first thing tomo morning...but why not dual boot windows ? can that be done in mac ? i dont know since i never used mac...

    Yeah it can but my father... but I can with parallels app without him discover I just need found one cracked :x

    Sent from my GT-S5570 using xda app-developers app