Sunday, February 17, 2013

Setting up Apktool

In case you did not have prior knowledge of how to setup apktool on a Linux  based machaine here is how. There are many tutorials dealing with how to set up the parts, individually, some good some not so much, but I will consolidate them here. Apktool is very useful for modifying android applications especially for theming, which I covered previously. I will guide you through the installation of JDK 6  and apktool so it is in your file path, ready to use.  To get started you will need the following:


  1. A linux distro, I am using Ubuntu 12.04, but the choice is yours although I would recommend a Debian based one, such as Ubuntu, Xubuntu, or Mint.
  2. Java JDK 6 (not open JDK or JDK7, the current version is 1.6.0_39, so the installation commands will be based on this. 
  3. Apktool.jar v1.52 along with the aapt and apktool script.


The first step is to download the files:
  • Jdk 6 found here the one you will need is jdk-6u39-linux-x64.bin , first accept the agreement and then you can download.  
  • Next you will need apktool, the thread can be found here, you need to download both the jar and aapt. 


To install JDK 6



First we will install the jdk 6 here is a good tutorial if you need it also:
  • First open a terminal and change directories to your wherever you downloaded jdk-6u39-linux-x64.bin.  For me the command is:
cd Downloads
  • Next you need to give the .bin file permissions, the command is:
chmod a+x jdk-6u39-linux-x64.bin 
  • Now we extract it with this command:
./jdk-6u39-linux-x64.bin 
  • Make a folder called jvm in /usr/lib/ you will have to use root (you have to type your password) so the command is:
sudo mkdir /usr/lib/jvm
  • Move your entire extracted folder to /usr/lib/jvm, assuming you are still in the folder of the extracted jdk file the command is:
sudo mv jdk1.6.0_39 /usr/lib/jvm
  • Finally to actually switch to jdk 39 you need to do the following:
wget http://webupd8.googlecode.com/files/update-java-0.5b
  • Then give that file permissions:
chmod +x update-java-0.5b
  • Finally to run the program:
sudo ./update-java-0.5b
  • Select jdk1.6.0_39 and click OK to test if everything worked type this 
java -version

javac-version

  • You should something similar (mine is actually 1.6.0_38, ), if not re-read or post in the comments:





To install apktool 


  • If you want further reading go here
  • First you will need to navigate to the location to where you downloaded apktool-install-linux-r05-ibot.tar.bz2 and apktool1.5.2.tar.bz2
  • Right click  and hit extract, then move the contents of the folder to the root of the Downloads folder, it should now look like this:

  •  For the next step you need to know the name of your home directory (often your username), we will use this to change the owner of the three files. Commands are as follows:

chown -R theapant:theapant '/home/theapant/Downloads/apktool.jar'

chown -R theapant:theapant '/home/theapant/Downloads/apktool'

chown -R theapant:theapant '/home/theapant/Downloads/aapt'



**note change theapant with whatever your username is, each time it appears**


  • Now we need to change the permissions (make executable)


sudo chmod +x '/home/theapant/Downloads/apktool.jar'

sudo chmod +x '/home/theapant/Downloads/apktool'

sudo chmod +x '/home/theapant/Downloads/aapt'

  • Finally just move the three files to /usr/local/bin, if you are still in the Downloads folder the commands are:



sudo mv apktool.jar /usr/local/bin

sudo mv apktool /usr/local/bin

sudo mv aapt /usr/local/bin



  • To test if everything worked just type apktool and if something like this comes up, you know it worked:


If you have gotten this far, then my other tutorial on theming by decompiling apks, will probably be benificial in learning some apktool commands/usage. 










6 comments:

  1. Thank you so much for this tutorial!! These is by far the most clearly laid out instructions that I have been able to find.

    Cheers!

    ReplyDelete
  2. Just wanted to thank you for this, i looked for a tutorial for about 3hrs now, and this is the only one that worked, and was simple to follow thank you so much for your time.

    ReplyDelete
  3. great! clear, step by step, easy to follow...what more we could wish for..? thanx so so much! you are the man!

    ReplyDelete
  4. Really simple and easy to follow guide. I wish it could be added to the project site

    ReplyDelete