Adventures of an Entrepreneur
  • Creating a Mobile Apps/Games Company

How to unpack / pack an APK file

3/31/2014

17 Comments

 
Did you know that when you download an Android App from Google Play or Amazon Store, you are actually downloading 1 single file?

That file has an APK extension and it is a kind of zip file. In fact, if you rename the extension from APK to ZIP and extract it, you will be able to navigate thru its asset files (images, audio,...). But unzipping the file does not make all its content accessible. E.g, if you try to open the AndroidManifest.xml, you will see that its content is not on plain text. So, if you want to correctly unpack all files from the APK, you can use a tool called apktool.

Here is a step-by-step tutorial to unpack an APK file:

1) Download the apktool file and its system dependency file, both available for free here. (For example, If you are using an MAC, you will have to download: apktool1.5.2.tar.bz2 and apktool-install-macosx-r05-ibot.tar.bz2). 

2) Extract both files to same directory (to make things easier :) )

3) Put the apk file that you want to unpack in that same directory

4) Unpack the apk doing with the following command: "./apktool d [your apk file]" (this is a MAC/linux
command, if you are using Windows, it should probably be "apktool d [your apk file]")

 That is it, the apktool will have created a new directory with the same name of your apk file where you will find the apk content.

If you want to pack that directory back again into an apk (let's say, after you edited something), just use the following command: "./apktool b [apk dir name] [apk file.apk]"




Important note: when you unpack and pack back the apk, it loses its android signature. So, if you want to install that apk on a device, you have to sign it again using the android Debug Key or your own key. You can do that by running the following command: "jarsigner -verbose -keystore [your keystore file] [your apk file.apk] [your keystore alias]"
17 Comments
RKY link
11/28/2014 03:16:17 pm

Thanks for your accurate and kind discriptions.
However please be more kind that you let me know what program or console should I use in order to execute your command.

God bless you!!

Reply
Admin
11/28/2014 03:56:06 pm

On your Mac console or Windows terminal

Reply
H.Brooks
3/31/2016 10:04:43 am

Hi, Thank you for this.

I'm trying to get the xml files from the APK, after following your instructions I get "smali" files?

Reply
myself
5/18/2016 10:13:57 am

wont find file. and " D" does not look like a valid option

Reply
Yigal
5/9/2017 03:44:30 pm

Hi
Is it possible to pack the full folder of kodi to apk and install it on other android?

Reply
Admin
5/9/2017 03:46:45 pm

I don't know what you mean by "kodi".

Reply
Yigal
5/9/2017 04:34:46 pm

I want to take a folder in the android and make the folder to be a apk file witch extract itself on other android device when I'll run it

Reply
Admin
5/9/2017 07:26:05 pm

I think you are mistaken on how the APK works. You cannot do that.

Reply
Yigal
5/10/2017 01:48:11 am

I know that apk file is actually a zip file.
Can I make the file on windows and run it an apk file on android? Just a file extracted to android folder?

Reply
Andrew Rukin
6/30/2017 02:31:29 pm

Apktool is a tool for reverse engineering 3rd party, closed, binary Android apps. It can decode resources to nearly original form and rebuild them after making some modifications.

You will find apktool indispensible if you want to extract resources (i.e. images from an Android application. Actually, the tool has no competitors at all!)

An online version of the apktool is available here: http://www.javadecompilers.com/apktool

Reply
Aditya
10/22/2017 10:44:56 am

I got error while running it for Linux that
. /apktool. sh : line 16 : $'\r' : command not found
. /apktool. sh : line 20 : $'\r' : command not found
. /apktool. sh : line 78 : syntax error : unexpected end of file

Please help!

Reply
Admin
10/22/2017 08:12:30 pm

Are u using the latest apktool version?

Reply
Sonik Strongheart link
7/3/2018 08:51:21 am

I am using Android 7.0 and Total Commander to unpack ApkZ into separated folders... Is there a 'jarsigner' for the Android command line environment???

Reply
john link
2/5/2019 01:44:59 am

can i installed in PC? like this APK <a href="assassinscreedidentityapk.com">assassins-creed-identity-apk/</a>

Reply
Noah link
4/8/2019 08:32:48 am

Thanks for the APK instructions!

Reply
Eddie
4/3/2020 07:10:04 am

Hi
I'm trying to resign an apk, but I am not sure how to find out my keystore file and keystore alias. This thread is 6 years old, but if you answer this it would be very helpful.
Thanks

Reply
Admin
4/3/2020 08:17:21 am

Your keystore file (aka certificate) is the one you created and used to sign the apk in the first time. If you don't have it anymore, there is no way of getting it back. With that said, you don't need to use the same keystore file. You can create a new one and use that sign, but the android system will treat it as different apk since it is not signed with the same certificate.

If you still have your keystore file, you can find the alias available in it. Just check how do it here: https://stackoverflow.com/questions/12893995/how-to-check-certificate-name-and-alias-in-keystore-files

Reply



Leave a Reply.

    Author

    This blog it not updated anymore.  

    Archives

    February 2015
    June 2014
    May 2014
    April 2014
    March 2014
    January 2014
    December 2013
    November 2013
    October 2013
    September 2013
    August 2013
    July 2013
    May 2013
    April 2013
    March 2013
    February 2013
    January 2013
    December 2012
    November 2012
    October 2012
    September 2012
    August 2012
    July 2012

    Categories

    All
    Data
    Event
    Fun
    Games
    Key Success Factors
    Management
    Marketing
    Mobile
    Monetization
    Movies
    Startup
    Statistics
    Technical
    Tutorial
    Videos

Powered by Create your own unique website with customizable templates.