[TOOL] [Windows] Batch APK Zipalign Tool v 2.0 (23/05/2022)

Search This thread

jineshpatel30

Senior Member
Nov 8, 2012
1,583
1,188
What's ziplign ?

Read,Android Developers site.https://developer.android.com/studio/command-line/zipalign

zipalign is an archive alignment tool that provides important optimization to Android application (APK) files. The purpose is to ensure that all uncompressed data starts with a particular alignment relative to the start of the file. Specifically, it causes all uncompressed data within the APK, such as images or raw files, to be aligned on 4-byte boundaries. This allows all portions to be accessed directly with mmap() even if they contain binary data with alignment restrictions. The benefit is a reduction in the amount of RAM consumed when running the application.

This tool should always be used to align your APK file before distributing it to end-users. The Android build tools can handle this for you. Android Studio automatically aligns your APK.


Why this tool is needed ?

There are a lot of APK modifications on XDA, most of which are done through APKTOOL (Thanks @iBotPeaches for this great tool)
But after apktool compilation, apks needs to be zipalign manually -> which is missing from some these Modded/Distributed Apks found in the forum.

So, I decided to go ahead and make simple tool for this task.
This tool will help end-users/devs in such cases.


How to Use ?

It's One-Click tool, As simple as it gets !


  1. Download & Extract Zip file from attachment.
  2. Put All apks in "Input" folder
    Do not leave "SPACES" in file name of APKs For example, Use "AppName_v1.apk" instead of "AppName v171.apk"
  3. Double Click the Batch file (.bat)
  4. You can find zipaliged APKs in "Output" folder after it's done.
That's It !!

PS : (Devs only) Use this tool **AFTER** signing APKs
Users don't need to worry about this because APKs you have/download are already signed.
 

Attachments

  • Zipalign_Tool_v1.0.zip
    122.3 KB · Views: 6,869
  • Zipalign_Tool_v2.0.zip
    326.5 KB · Views: 2,552
Last edited:

jineshpatel30

Senior Member
Nov 8, 2012
1,583
1,188
FAQs

# How to know whether APKs are zipaligned or not after using this tool ?
Check file size of APK Before & After (In Input & Output folders). You will see the differnce in file size on bytes level So, you need to open full property of file via right click.

If file size if exactly the same, means APK was already zipaligned

# How to know whether APKs i have are already zipaligned or not ?
As of now there's no method to my knowledge. So, you need to go through above process.

In general, APKs directly from PlayStore (you backup/apkmirror) are zipaligned so you don't need to zipalign them unless there's some modifications performed on it.


Change log

v1.0 Release 2017

  • Initial Release
  • Latest available zipalign binary
v2.0 Release 2022
  • Based on Android SDK Build-Tools 30.1.0 and should be compatible with latest Android versions (A9-A12+)
 
Last edited:

jineshpatel30

Senior Member
Nov 8, 2012
1,583
1,188

Update after a long time.


v2 is based on Android SDK Build-Tools 30.1.0 and should be compatible with latest Android versions (A9-A12+)

Happy Modding!
 
Last edited:
  • Like
Reactions: JonW434 and DefyCM

Colorido10

Member
Apr 10, 2019
13
1
i get this error a mod apk
Code:
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed collecting certificates for /data/app/vmdl262490375.tmp/base.apk: Failed to collect certificates from /data/app/vmdl262490375.tmp/base.apk: META-INF/APKEASYT.SF indicates /data/app/vmdl262490375.tmp/base.apk is signed using APK Signature Scheme v2, but no such signature was found. Signature stripped?]
 

CVC108

New member
May 13, 2020
1
0
Command file current zipalign.bat:
for %%X in (.\Input\*.apk) do (
echo Zipaligning - %%~nX.apk
.\Tools\zipalign -cv 4 %%X
.\Tools\zipalign -fv 4 %%X .\Output\%%~nX.apk
)

Maybe it should be reversed like this:
for %%X in (.\Input\*.apk) do (
echo Zipaligning - %%~nX.apk
rem To align infile.apk and save it as outfile.apk
.\Tools\zipalign -fv 4 %%X .\Output\%%~nX.apk
rem check alignment outfile.apk only after having zipalign (does not modify file)
.\Tools\zipalign -cv 4 %%X
)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 11
    What's ziplign ?

    Read,Android Developers site.https://developer.android.com/studio/command-line/zipalign

    zipalign is an archive alignment tool that provides important optimization to Android application (APK) files. The purpose is to ensure that all uncompressed data starts with a particular alignment relative to the start of the file. Specifically, it causes all uncompressed data within the APK, such as images or raw files, to be aligned on 4-byte boundaries. This allows all portions to be accessed directly with mmap() even if they contain binary data with alignment restrictions. The benefit is a reduction in the amount of RAM consumed when running the application.

    This tool should always be used to align your APK file before distributing it to end-users. The Android build tools can handle this for you. Android Studio automatically aligns your APK.


    Why this tool is needed ?

    There are a lot of APK modifications on XDA, most of which are done through APKTOOL (Thanks @iBotPeaches for this great tool)
    But after apktool compilation, apks needs to be zipalign manually -> which is missing from some these Modded/Distributed Apks found in the forum.

    So, I decided to go ahead and make simple tool for this task.
    This tool will help end-users/devs in such cases.


    How to Use ?

    It's One-Click tool, As simple as it gets !


    1. Download & Extract Zip file from attachment.
    2. Put All apks in "Input" folder
      Do not leave "SPACES" in file name of APKs For example, Use "AppName_v1.apk" instead of "AppName v171.apk"
    3. Double Click the Batch file (.bat)
    4. You can find zipaliged APKs in "Output" folder after it's done.
    That's It !!

    PS : (Devs only) Use this tool **AFTER** signing APKs
    Users don't need to worry about this because APKs you have/download are already signed.
    7
    FAQs

    # How to know whether APKs are zipaligned or not after using this tool ?
    Check file size of APK Before & After (In Input & Output folders). You will see the differnce in file size on bytes level So, you need to open full property of file via right click.

    If file size if exactly the same, means APK was already zipaligned

    # How to know whether APKs i have are already zipaligned or not ?
    As of now there's no method to my knowledge. So, you need to go through above process.

    In general, APKs directly from PlayStore (you backup/apkmirror) are zipaligned so you don't need to zipalign them unless there's some modifications performed on it.


    Change log

    v1.0 Release 2017

    • Initial Release
    • Latest available zipalign binary
    v2.0 Release 2022
    • Based on Android SDK Build-Tools 30.1.0 and should be compatible with latest Android versions (A9-A12+)
    2

    Update after a long time.


    v2 is based on Android SDK Build-Tools 30.1.0 and should be compatible with latest Android versions (A9-A12+)

    Happy Modding!
    1
    Tried this. Nothing in the output folder
    I'm not actively maintaining this tool due to personal commitments. Theoretically it should still work even with older binaries but if you are looking for specific support I suggest search for other/newer threads.
    1
    I'm not actively maintaining this tool due to personal commitments. Theoretically it should still work even with older binaries but if you are looking for specific support I suggest search for other/newer threads.
    I tried it again. It works like a charm. Awesome. Thank you!