Stay organized with collections Save and categorize content based on your preferences.

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 mmap(2), 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:

  • If you use apksigner, 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.
  • If you use jarsigner, zipalign must only be performed after the APK file has been signed.

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 -p to ensure that they're aligned to a 4KiB page boundary suitable for mmap(2). 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.

To align infile.apk and save it as outfile.apk:

zipalign -p -f -v 4 infile.apk outfile.apk

To confirm the alignment of existing.apk:

zipalign -c -v 4 existing.apk

You can use zipalign -h to see the full set of flags supported.