zipalign is a zip archive alignment tool. It ensures that all uncompressed files in the archive
are aligned relative to the start of the file. This allows those files to be accessed directly via
removing the need to copy this data in RAM and reducing your app's memory usage.
zipalign should be used to optimize your APK file before distributing it to end-users. This is done automatically if you build with Android Studio. This documentation is for maintainers of custom build systems.
Caution: You must use zipalign at one of two specific points in the app-building process, depending on which app-signing tool you use:
The alignment is achieved by altering the size of the "extra" field in the zip Local File Header sections. Existing data in the "extra" fields may be altered by this process.
For more information about how to use zipalign when building your application, please read Signing Your Application.
If your APK contains shared libraries (
.so files), you should 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, 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
zipalign -c -v 4 existing.apk
You can use
zipalign -h to see the full set of flags supported.