How to unzip, edit and zip an android apk

AndroidReverse EngineeringReverse

Android Problem Overview


I have an android apk and I deleted my source code and dont have the project again, I want to change the version code of the old apk. my question is how do I unzip and repack the apk so I can use the. am using a mac system. I saw so many things for windows but i couldnt find for mac.I need help please

Android Solutions


Solution 1 - Android

unzip apk files

The simplest method is executing unzip command:

> unzip xxx.apk -d xxx

A directory xxx will be generated to store unzipped files. Actually, .apk files are same as .zip files. Execute command file XXX.apk to see that.

get readable text files from apk

If you want readable text files such as the manifest file, I would suggest you to use the apktool. We could install the apktool easily with Homebrew:

brew install apktool

then get the readable text files:

apktool d xxx.apk

after the previous command, a xxx directory contains readable text files and others would be there.

edit zip files

If you want to edit a zip file in place, the Keka might be a good option.

Solution 2 - Android

To give a complete answer for unpacking, editing and packing on Mac:

Unpacking / Unzipping

As Liu Tao stated, the easiest way to unpack a *.apk file on mac is to use the following command:

unzip xxx.apk -d xxx

This is because an *.apk file is nothing else than a zip file. Again, as Liu Tao stated, this can be found out with the file command.

file xxx.apk

Which will show an output that looks something like this:

> xxx.apk: Zip archive data, at least v2.0 to extract

Editing

I think this is self-explanatory. Go into the folder to which you exported the *.apk contents and edit them as you would usually do.

Packing / Zipping

On Mac, this is also quite straight-forward. You can use the zip command to pack all the files back into an *.apk file.

zip -r xxx.apk xxx/

Solution 3 - Android

You want to use APKTool. It will handle the unzip and rebuild for you: http://ibotpeaches.github.io/Apktool/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1662302View Question on Stackoverflow
Solution 1 - AndroidLiu TaoView Answer on Stackoverflow
Solution 2 - AndroidAndreas ZwettlerView Answer on Stackoverflow
Solution 3 - AndroidBlackdragon1400View Answer on Stackoverflow