zipalign

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

    Caution: You must use zipalign at one of two specific points in the app-building process, depending on which app-signing tool you use:

    • If you use , zipalign must only be performed before the APK file has been signed. If you sign your APK using apksigner and make further changes to the APK, its signature is invalidated.

    For more information about how to use zipalign when building your application, please read Signing Your Application.

    To align and save it as outfile.apk:

    1. zipalign -c -v <alignment> existing.apk

    The is an integer that defines the byte-alignment boundaries. This must always be 4 (which provides 32-bit alignment) or else it effectively does nothing.

    Flags:

    • -f : overwrite existing outfile.zip
    • : outfile.zip should use the same page alignment for all shared object files within infile.zip
    • -c : confirm the alignment of the given file