Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP A_U

30th March 2013, 07:25 PM   |  #1  
OP Recognized Contributor / Themer
Flag Wichita
Thanks Meter: 4,604
 
3,223 posts
Join Date:Joined: Jun 2012
More
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:
    apktool if name-of-the-app .apk
    For example, once the command is executed correctly, it will look like this -

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

    Code:
    apktool d name-of-the-app .apk
    For example -

    Code:
    apktool d framework-res.apk
  • 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:
    apktool b name-of-the-app-folder
  • NOTE - While recompiling the app, you just need to type the name of the folder the app's files contains.
    For example -

    Code:
    apktool b framework-res
    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


Quote:

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] -
  • then type the following command -

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


    Code:
    java -jar signapk.jar certificate.pem key.pk8 framework-res.apk framework-res-signed.apk
  • 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 !


If you have any errors or problems related to apktool, post them here, I will try to solve them.
Attached Files
File Type: zip SignApk.zip - [Click for QR Code] (9.2 KB, 13439 views)
The Following 125 Users Say Thank You to A_U For This Useful Post: [ View ]
30th March 2013, 07:26 PM   |  #2  
OP Recognized Contributor / Themer
Flag Wichita
Thanks Meter: 4,604
 
3,223 posts
Join Date:Joined: Jun 2012
More


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:
    su
    tar -C /usr/local/bin -xvf <zipped file name>
    tar -C /usr/local/bin -xvf <zipped file name> (for the second file)
  • 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"

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





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 by A_U; 19th August 2013 at 09:28 PM.
The Following 13 Users Say Thank You to A_U For This Useful Post: [ View ]
30th March 2013, 07:34 PM   |  #3  
dzeig's Avatar
Senior Member
Thanks Meter: 69
 
291 posts
Join Date:Joined: Jan 2013
for decompiling - compiling apk, use apk multi tool, waaay simpler. (and stable).
30th March 2013, 07:34 PM   |  #4  
Senior Member
Flag Recife
Thanks Meter: 400
 
2,240 posts
Join Date:Joined: Feb 2012
More
Re: [GUIDE][HOW-TO] Decompile and Compile apps using Apktool in 5 Simple Steps
Thanx will read it

Sent from my GT-S5570 using xda app-developers app
30th March 2013, 07:35 PM   |  #5  
OP Recognized Contributor / Themer
Flag Wichita
Thanks Meter: 4,604
 
3,223 posts
Join Date:Joined: Jun 2012
More
Quote:
Originally Posted by dzeig

for decompiling - compiling apk, use apk multi tool, waaay simpler. (and stable).

yea its easier but i prefer apktool simply...
The Following User Says Thank You to A_U For This Useful Post: [ View ]
30th March 2013, 07:43 PM   |  #6  
Senior Member
Flag Recife
Thanks Meter: 400
 
2,240 posts
Join Date:Joined: Feb 2012
More
Re: [GUIDE][HOW-TO] Decompile and Compile apps using Apktool in 5 Simple Steps
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
30th March 2013, 07:45 PM   |  #7  
hsay's Avatar
Senior Member
Flag pune
Thanks Meter: 565
 
1,497 posts
Join Date:Joined: May 2012
More
Re: [GUIDE][HOW-TO] Decompile and Compile apps using Apktool in 5 Simple Steps
Quote:
Originally Posted by The Alchemist

yea its easier but i prefer apktool simply...

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
The Following 2 Users Say Thank You to hsay For This Useful Post: [ View ]
30th March 2013, 07:49 PM   |  #8  
Senior Member
Flag Recife
Thanks Meter: 400
 
2,240 posts
Join Date:Joined: Feb 2012
More
Re: [GUIDE][HOW-TO] Decompile and Compile apps using Apktool in 5 Simple Steps
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
30th March 2013, 07:52 PM   |  #9  
OP Recognized Contributor / Themer
Flag Wichita
Thanks Meter: 4,604
 
3,223 posts
Join Date:Joined: Jun 2012
More
Quote:
Originally Posted by gabrielking9

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

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...
30th March 2013, 08:44 PM   |  #10  
Senior Member
Flag Recife
Thanks Meter: 400
 
2,240 posts
Join Date:Joined: Feb 2012
More
Re: [GUIDE][HOW-TO] Decompile and Compile apps using Apktool in 5 Simple Steps
Quote:
Originally Posted by The Alchemist

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

The Following User Says Thank You to gabrielking9 For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
apktool, guide, how-to, linux, sign
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes