Jump to content

Packing an APK

From Battle Cats Game Modding Wiki
Revision as of 13:34, 19 January 2026 by Fieryhenry (talk | contribs) (Zipalign)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Once you have finished your mod you need to pack it back into an apk file

Packing as a zip file

Note you can only do this method if you treated the apk as a zip file during the original unpacking step. If your resources (such as AndroidManifest.xml) have been decoded, you cannot just zip up the contents of the apk.

Select all files and folders inside the extracted APK directory, then compress them into a ZIP archive - do not just compress the outer directory, this will lead to issues.

Note that in some versions of android, the resources.arsc file should not be compressed and may be required to be aligned to a 4-byte boundary. To fix this, you should use the zipalign tool to do this:

zipalign 4 path/to/input.apk path/to/output.apk

If you want to overwrite the original file, use the -f flag.

Change path/to/input.apk with the file location of the input apk.

Change path/to/output.apk with the file location to write the new apk file to. (If you want to overwrite the input file, make this the same value)

Pack using Apktool

Apktool can pack the apk as well as re-encode any resources.

See install to install apktool to your system.

Then to pack the APK, the following command can be used:

apktool b path/to/apk_folder -o path/to/output_apk.apk

Replacing path/to/apk_folder with the location of the extracted APK contents.

-o path/to/output_apk.apk is optional, but useful if you want to place the packed files in a specific location (default is dist/name.apk), replacing path/to/output_apk.apk with the location of the path to write the final apk to.

Note that sometimes apktool may fail to pack some resources and so when you build the apk, it may fail to build correctly. If this is the case, you may have to go back to the extracting step and use the --no-res flag.