Installing javac for Apktool on linux

The build steps of the latest Apktool is detailed below


It uses something called gradlew to build the latest version of the binary.

The instructions are as follows:

We use gradle to build. Its pretty easy. First clone the REPO.

git clone git://
Move into the directory.

cd Apktool
Issue the build.

./gradlew build
Then look in

Other commands such as clean are

./gradlew clean

If you attempt that and dont have JDK installed, it will error out.

You need to download the latest version of the JDK available as a .tar.gz file at

I used jdk-7u9-linux-i586.tar.gz

Once extracted, set the path as the path of the folder containing the bin folder (which contains javac). Note that the path should be the parent of the bin folder, and not include the bin folder itself.

export JAVA_HOME=/home/droidzone/android/java/jdk1.7.0_09

Here, jdk1.7.0_09/bin contains javac.

The final file will be produced in a location brut.apktool/apktool-cli/build/libs/ relative to the parent and named of the form apktool-cli-1.5.1-SNAPSHOT.jar


cp brut.apktool/apktool-cli/build/libs/*jar ./

should get you the latest file.

Note that you need the wrapper too.

tar -jxvvf apktool-install-linux-r04-brut1.tar.bz2

Finally since the apktool refers to a file named apktool.jar, create a symlink.


Possible errors:

Exception in thread "main" java.lang.UnsupportedClassVersionError: brut/apktool/Main : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(
        at Method)
        at java.lang.ClassLoader.loadClass(
        at sun.misc.Launcher$AppClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(
        at java.lang.ClassLoader.loadClassInternal(
Could not find the main class: brut.apktool.Main. Program will exit.

That happens when your main system version java is older than version 7.

You can solve it either by:

1. Upgrading your main java version

2. Setting the PATH of your local java to override your system java.

Eg: If PATH is :/usr/bin:~/bin, make it ~/bin:/usr/bin

3. Creating a symlink in /usr/bin, point it to your version

cd /usr/bin


mv java java.old

ln -s /home/droidzone/android/java/jdk1.7.0_09/bin/java java



You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.