zipalign is a zip archive alignment tool that helps ensure that all uncompressed files
in the archive
are aligned relative to the start of the file. This lets the files be accessed directly via
, removing the need to copy this data in RAM and reducing your app's memory usage.
zipalign to optimize your APK file before distributing it to
end users. If you build using Android Studio, which uses the Android Gradle plugin (AGP), this is
done automatically. In this case, you should still use
zipalign to verify that the APK
is aligned, but you don't need to align it. This documentation is mainly for maintainers of
custom build systems.
Caution: You must use
zipalign at a specific point in
the build process. That point depends on which app-signing tool you use:
To achieve alignment,
zipalign alters the size of the
"extra" field in the zip Local File Header
sections. This process can also alter existing data in the
If your APK contains shared libraries (
.so files), use
to ensure that they're aligned to a 4KiB page boundary suitable for
other files, whose alignment is determined by the mandatory alignment argument to
zipalign, Android Studio aligns to 4 bytes on both 32-bit and 64-bit systems.
infile.apk and save it as
zipalign -p -f -v 4 infile.apk outfile.apk
To confirm the alignment of
existing.apk, use the following command. If you use
Android Studio or AGP to build, this is the command you should use to verify that your APK is
zipalign -c -v 4 existing.apk
The following table lists the available
|Checks alignment only (does not modify file).
|Overwrites existing output file.
|Displays tool help.
|Recompresses using Zopfli.