• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[GUIDE][14.10][15.04][15.10]APKTool for Ubuntu (Automate Installation)

Search This thread

Calin

Retired Forum Moderator / Recognized Developer
Nov 22, 2012
3,031
5,186
23
Oradea
apktool-e1444745373891-810x298_c.jpeg

Intro

  • This little guide was accessed by many people,and this thread already got one year from it's release, so in order to make it even more simple for the users and continue to use and install APKTool to their Linux distributions i created an automated script, which it will upgrade an existing APKTool with a new version or install everything for the user.
    So basically if you saw my thread sometimes now you absolutely don't need anymore to write the commands and do all these stuff manually cause the script will now do it for you.
    For download, now you get the zip containing everything from the attachments.

How to run the script

  • To run the script is very simple, just download the zip, unpack it to your desktop for example and finally now open a terminal window from the folder where the script is located, and now type:

Code:
./Script.sh
  • If for some reason fails, just open the proprieties of the file, and make it executable... It will work.


How does it work?

  • The basic commands are this :
    • apktool if framework-res.apk: This command is recommended to be done at the first run, because this will allow to install the framework-res of your ROM which will be used in future to decompile the APKs based on that API level
    • apktool d SystemUI.apk OUT: This command will decompile an apk to the OUT folder but if you want to choose an other name, you're freely to do it.
      The command also can be wrote in this manner: apktool d SystemUI.apk and the apk will be decompiled into a folder with the same name of the app, in this case SystemUI
    • apktool b SystemUI: When you will finish to work on an APK obviously you will also need to recompile the apk with the changes so to do that you will need to use this command which as stated will recompile the apk with the changes.
    • java -jar signapk.jar testkey.x509.pem testkey.pk8 name_of_app.apk name_of_app-signed.apk: This command will allow you to sign your apk once it's compiled, and i suggest you to do it every time you made some changes because on Android when you will try to install it or push it to system for example it will not work in most of the cases so it's better always to sign the apk always. The command is very simple to use it, just write it into a terminal window and the signed apk will be made in a few seconds.


  • So pretty much that's it :)
    If you find any kind of problem during the recompilation of an APK don't panic, just watch again the sources and the guide you are following to see if you made good the steps, or search on Google, your best friend for these things :D ;)
  • You can also write it here if you want and I or some other user will help you out with your problem
    Thanks, and i hope this will help some people
 
Last edited:

ShinySide

Inactive Recognized Developer
Nov 30, 2013
3,965
4,819
IHB
Nice guide :good: Think its the best Ive seen for installing on Linux. Wish I found this the first time I installed it on Linux.

Im lazy, hate typing, and change distros often so i turned it all into a script a while back. But think this is great for newbies.

Great work bud.

edit-

Posted 2 weeks ago and only 3 thanks? Come on people. Be thankful for this. Not too long ago you could barely even find one guide for this let alone one put together well. Hit the thanksssssss.
 
Last edited:

bm19981217

Senior Member
Jun 5, 2014
69
20
I already searched for it but didn't find an answer: How do I sign an apk on ubuntu?
Nice guide, will do it AS soon AS I have time.
Sent from my Nexus 5 using XDA Free mobile app
 
Last edited:

Calin

Retired Forum Moderator / Recognized Developer
Nov 22, 2012
3,031
5,186
23
Oradea
Nice guide :good: Think its the best Ive seen for installing on Linux. Wish I found this the first time I installed it on Linux.

Im lazy, hate typing, and change distros often so i turned it all into a script a while back. But think this is great for newbies.

Great work bud.

edit-

Posted 2 weeks ago and only 3 thanks? Come on people. Be thankful for this. Not too long ago you could barely even find one guide for this let alone one put together well. Hit the thanksssssss.
Thanks man :))
I will add also a mini guide for signing this afternoon

edit. added mini guide also for signing
 
Last edited:
  • Like
Reactions: ANDjROID
E

EnricoD

Guest
great work, very useful for noobs :)

If You install oracle's java You don't need the open jdk

This is user's choice
;)

Why not the 7 instead of 6th?
Code:
sudo apt-get install openjdk-7-jre

It's possible also to make this process faster by adding a wget instead of downloading all apktool things from the website

for example i uploaded apktool files on my dropbox and I download everytime I have to install apktool by simply running

Code:
wget https://www.dropbox.com/s/6s9bxszxjl7wclz/apktool.tar.gz

then

Code:
tar -zxvf apktool.tar.gz

then

Code:
cd apktool

You can also run single commands to make the installation process faster

Code:
sudo chmod +x aapt apktool apktool.jar

Code:
sudo chown -R [COLOR="red"][B]yourusername[/B][/COLOR] aapt apktool apktool.jar

enricod@enricod-Aspire-5920G:~/Scrivania/apktool$

Code:
sudo cp aapt apktool apktool.jar /usr/local/bin

just hints :)
 

paulle

Senior Member
Nov 1, 2010
1,295
275
ubuntu 14.04 ia32libs

in ubuntu 14.04 (64bit) the ia32libs aren't available.

Package ia32-libs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source
However the following packages replace it:
lib32z1 lib32ncurses5 lib32bz2-1.0

Package 'ia32-libs' has no installation candidate
 
Last edited:

Calin

Retired Forum Moderator / Recognized Developer
Nov 22, 2012
3,031
5,186
23
Oradea
in ubuntu 14.04 (64bit) the ia32libs aren't available.

Package ia32-libs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source
However the following packages replace it:
lib32z1 lib32ncurses5 lib32bz2-1.0

Package 'ia32-libs' has no installation candidate
These are required optionally just in case the APKTool may fail during his running
but if they are necessary type the following commands:

Code:
sudo -i
cd /etc/apt/sources.list.d
echo "deb http://old-releases.ubuntu.com/ubuntu/ raring main restricted universe multiverse" >ia32-libs-raring.list
apt-get update
apt-get install ia32-libs
 
Last edited:
  • Like
Reactions: ANDjROID

typos1

Senior Member
Apr 3, 2007
9,447
1,716
UK
I ve got Android sdk, Java and adb already on my 64 bit system, is it ok to leave out installation of those bits and just start by installing the APK tool, but miss out the 32bit libs cos I already have them ? Thanks
 

brymaster5000

Inactive Recognized Contributor
Jan 9, 2012
2,382
3,138
New Hampshire
Excellent. Many users should find this very useful.
:highfive:
One thing I want people to note is that I have successfully been using 14.04 ubuntu with java 8 and apktool v2.0.0b9 installed. Granted I only build kernels from source and not AOSP...but figured I would let people know.
 
  • Like
Reactions: fairxda and Calin

ShinySide

Inactive Recognized Developer
Nov 30, 2013
3,965
4,819
IHB
Excellent. Many users should find this very useful.
:highfive:
One thing I want people to note is that I have successfully been using 14.04 ubuntu with java 8 and apktool v2.0.0b9 installed. Granted I only build kernels from source and not AOSP...but figured I would let people know.

Mine will decompile and recompile just fine with Oracle 8 but if say the apk is framework or system ui phone won't boot. If a non critical apk it won't show/install after pushing or flashing to device
 

Slimegod

Senior Member
Mar 12, 2011
2,300
99
When I want to decompile say a jar file (framework.jar) where does it go? I'm use to using apktool for windows and I'm new to using linux and this is kinda different for me. Sorry for the noobness. Where do the files downloaded go. Are they all suppose to be in one folder?
 
Last edited:

ShinySide

Inactive Recognized Developer
Nov 30, 2013
3,965
4,819
IHB
When I want to decompile say a jar file (framework.jar) where does it go? I'm use to using apktool for windows and I'm new to using linux and this is kinda different for me. Sorry for the noobness. Where do the files downloaded go. Are they all suppose to be in one folder?

Are you talking about apktool.jar,apktool, and aapt? They are moved to usr/local/bin in the system directory. After you have done the guide you can make a folder anywhere you want, put your apks you want to mod in it and type the commands. Its not like windows where you have to put apktool.jar, apktool, and aapt in a folder on C and had to work in that folder.
 

Slimegod

Senior Member
Mar 12, 2011
2,300
99
Are you talking about apktool.jar,apktool, and aapt? They are moved to usr/local/bin in the system directory. After you have done the guide you can make a folder anywhere you want, put your apks you want to mod in it and type the commands. Its not like windows where you have to put apktool.jar, apktool, and aapt in a folder on C and had to work in that folder.

OK. I put my aapt in the home directory. Need to do the process all over. When I ran the sudo command that's in the OP for the apktool and the apktool.jar it said command not found until I put it in the home directory and extracted it, they were in the downloads directory. Wasn't really sure where they went. The directions in the OP wasn't to articulate when it came to actually where the folders went.
 

ShinySide

Inactive Recognized Developer
Nov 30, 2013
3,965
4,819
IHB
OK. I put my aapt in the home directory. Need to do the process all over. When I ran the sudo command that's in the OP for the apktool and the apktool.jar it said command not found until I put it in the home directory and extracted it, they were in the downloads directory. Wasn't really sure where they went. The directions in the OP wasn't to articulate when it came to actually where the folders went.

I'll make it super duper easy for you hold on a second

Here, make a new document in your home folder, name it apkt , and paste this in it

#!/bin/bash


# Install apktool
cd ~/Desktop
wget https://android-apktool.googlecode.com/files/apktool1.5.2.tar.bz2
wget https://android-apktool.googlecode.com/files/apktool-install-linux-r05-ibot.tar.bz2
tar jxf apktool1.5.2.tar.bz2
tar jxf apktool-install-linux-r05-ibot.tar.bz2
cd apktool1.5.2
mv apktool.jar ../
cd ../
cd apktool-install-linux-r05-ibot
mv aapt apktool ../
sudo chown -R USERNAME:USERNAME /home/USERNAME/Desktop/aapt
sudo chown -R USERNAME:USERNAME /home/USERNAME/Desktop/apktool
sudo chown -R USERNAME:USERNAME /home/USERNAME/Desktop/apktool.jar
sudo chmod +x /home/USERNAME/Desktop/aapt
sudo chmod +x /home/USERNAME/Desktop/apktool
sudo chmod +x /home/USERNAME/Desktop/apktool.jar
sudo mv /home/USERNAME/Desktop/aapt /usr/local/bin/
sudo mv /home/USERNAME/Desktop/apktool /usr/local/bin/
sudo mv /home/USERNAME/Desktop/apktool.jar /usr/local/bin/
rm -rf /home/USERNAME/Desktop/apktool1.5.2
rm -rf /home/USERNAME/Desktop/apktool1.5.2.tar.bz2
rm -rf /home/USERNAME/Desktop/apktool-install-linux-r05-ibot
rm -rf /home/USERNAME/Desktop/apktool-install-linux-r05-ibot.tar.bz2


Replace all the USERNAMES with your user name. And save it. Close it, right click it, select permissions and tick execute. Open your terminal and type sudo ./apkt and put oyur password in, itll do it all for you.
 
Last edited:
  • Like
Reactions: DarkAngel

Slimegod

Senior Member
Mar 12, 2011
2,300
99
I'll make it super duper easy for you hold on a second

Here, make a new document in your home folder, name it apkt , and paste this in it

#!/bin/bash


# Install apktool
cd ~/Desktop
wget https://android-apktool.googlecode.com/files/apktool1.5.2.tar.bz2
wget https://android-apktool.googlecode.com/files/apktool-install-linux-r05-ibot.tar.bz2
tar jxf apktool1.5.2.tar.bz2
tar jxf apktool-install-linux-r05-ibot.tar.bz2
cd apktool1.5.2
mv apktool.jar ../
cd ../
cd apktool-install-linux-r05-ibot
mv aapt apktool ../
sudo chown -R USERNAME:USERNAME /home/USERNAME/Desktop/aapt
sudo chown -R USERNAME:USERNAME /home/USERNAME/Desktop/apktool
sudo chown -R USERNAME:USERNAME /home/USERNAME/Desktop/apktool.jar
sudo chmod +x /home/USERNAME/Desktop/aapt
sudo chmod +x /home/USERNAME/Desktop/apktool
sudo chmod +x /home/USERNAME/Desktop/apktool.jar
sudo mv /home/USERNAME/Desktop/aapt /usr/local/bin/
sudo mv /home/USERNAME/Desktop/apktool /usr/local/bin/
sudo mv /home/USERNAME/Desktop/apktool.jar /usr/local/bin/
rm -rf /home/USERNAME/Desktop/apktool1.5.2
rm -rf /home/USERNAME/Desktop/apktool1.5.2.tar.bz2
rm -rf /home/USERNAME/Desktop/apktool-install-linux-r05-ibot
rm -rf /home/USERNAME/Desktop/apktool-install-linux-r05-ibot.tar.bz2


Replace all the USERNAMES with your user name. And save it. Close it, right click it, select permissions and tick execute. Open your terminal and type sudo ./apkt and put oyur password in, itll do it all for you.

All the apktool files I downloaded go in that folder or stay in the usr/local/bin?

Edit: just noticed it's in the proper place. Thanks man really appreciate it. One last question. What other files go in the usr/local/bin besides aapt and apktool? The apktool ibot tar or the apktool1.5.2 tar? I asked because when I ran the sudo cp command it gave me a error on the apktool1.5.2. Said it was omitting it. I can always put it in manually in the right directory. Just wanted to know why it did that.
 
Last edited:

ShinySide

Inactive Recognized Developer
Nov 30, 2013
3,965
4,819
IHB
All the apktool files I downloaded go in that folder or stay in the usr/local/bin?

Edit: just noticed it's in the proper place. Thanks man really appreciate it. One last question. What other files go in the usr/local/bin besides aapt and apktool? The apktool ibot tar or the apktool1.5.2 tar? I asked because when I ran the sudo cp command it gave me a error on the apktool1.5.2. Said it was omitting it. I can always put it in manually in the right directory. Just wanted to know why it did that.

If you ran the script I just gave you it did everything for you and you have to do nothing else.

Just apktool apktool.jar and aapt the tar files are deleted. Named just like that. Im not sure what you did.
 
  • Like
Reactions: Slimegod

Top Liked Posts

  • There are no posts matching your filters.
  • 94
    apktool-e1444745373891-810x298_c.jpeg

    Intro

    • This little guide was accessed by many people,and this thread already got one year from it's release, so in order to make it even more simple for the users and continue to use and install APKTool to their Linux distributions i created an automated script, which it will upgrade an existing APKTool with a new version or install everything for the user.
      So basically if you saw my thread sometimes now you absolutely don't need anymore to write the commands and do all these stuff manually cause the script will now do it for you.
      For download, now you get the zip containing everything from the attachments.

    How to run the script

    • To run the script is very simple, just download the zip, unpack it to your desktop for example and finally now open a terminal window from the folder where the script is located, and now type:

    Code:
    ./Script.sh
    • If for some reason fails, just open the proprieties of the file, and make it executable... It will work.


    How does it work?

    • The basic commands are this :
      • apktool if framework-res.apk: This command is recommended to be done at the first run, because this will allow to install the framework-res of your ROM which will be used in future to decompile the APKs based on that API level
      • apktool d SystemUI.apk OUT: This command will decompile an apk to the OUT folder but if you want to choose an other name, you're freely to do it.
        The command also can be wrote in this manner: apktool d SystemUI.apk and the apk will be decompiled into a folder with the same name of the app, in this case SystemUI
      • apktool b SystemUI: When you will finish to work on an APK obviously you will also need to recompile the apk with the changes so to do that you will need to use this command which as stated will recompile the apk with the changes.
      • java -jar signapk.jar testkey.x509.pem testkey.pk8 name_of_app.apk name_of_app-signed.apk: This command will allow you to sign your apk once it's compiled, and i suggest you to do it every time you made some changes because on Android when you will try to install it or push it to system for example it will not work in most of the cases so it's better always to sign the apk always. The command is very simple to use it, just write it into a terminal window and the signed apk will be made in a few seconds.


    • So pretty much that's it :)
      If you find any kind of problem during the recompilation of an APK don't panic, just watch again the sources and the guide you are following to see if you made good the steps, or search on Google, your best friend for these things :D ;)
    • You can also write it here if you want and I or some other user will help you out with your problem
      Thanks, and i hope this will help some people
    5
    Nice guide :good: Think its the best Ive seen for installing on Linux. Wish I found this the first time I installed it on Linux.

    Im lazy, hate typing, and change distros often so i turned it all into a script a while back. But think this is great for newbies.

    Great work bud.

    edit-

    Posted 2 weeks ago and only 3 thanks? Come on people. Be thankful for this. Not too long ago you could barely even find one guide for this let alone one put together well. Hit the thanksssssss.
    2
    Just wanted to say a big thankyou[emoji106] made installing on Linux mint 18 so easy, now I'm ready to take on 3minit battery.

    Sent from my blacked out Ressurected and Remixed GT-I9305 using Tapatalk
    2
    Code:
    [email protected]:~/Desktop$ apktool if framework-res.apk
    Exception in thread "main" brut.androlib.AndrolibException: Invalid value type: 0
    	at brut.androlib.res.data.value.ResValueFactory.factory(ResValueFactory.java:64)
    	at brut.androlib.res.decoder.ARSCDecoder.readValue(ARSCDecoder.java:242)
    	at brut.androlib.res.decoder.ARSCDecoder.readComplexEntry(ARSCDecoder.java:230)
    	at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:200)
    	at brut.androlib.res.decoder.ARSCDecoder.readConfig(ARSCDecoder.java:188)
    	at brut.androlib.res.decoder.ARSCDecoder.readType(ARSCDecoder.java:156)
    	at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:113)
    	at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:78)
    	at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:47)
    	at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:39)
    	at brut.androlib.res.AndrolibResources.installFramework(AndrolibResources.java:678)
    	at brut.androlib.res.AndrolibResources.installFramework(AndrolibResources.java:660)
    	at brut.androlib.Androlib.installFramework(Androlib.java:641)
    	at brut.apktool.Main.cmdInstallFramework(Main.java:240)
    	at brut.apktool.Main.main(Main.java:87)
    [email protected]:~/Desktop$

    I am geting that error on Ubuntu 14.10 64bit when I run apktool if framework-res.apk. I am trying use this on cm12.1.
    Yeah sorry i didn't updated apktool for android 5.1 but i will update it soon ;)