What's the use of Android Zipalign

3.2k views Asked by At

I was reading about zipalign in android. I am new to this concept. I search on google for the same but didn't find any appropriate answer.

Can anyone tell me what's the actual use of zipalign?

Is signed apk and zipalign is the same?

Thanks in advance!

2

There are 2 answers

0
Anupam On

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.

For more details visit -

https://developer.android.com/studio/command-line/zipalign

And this -

https://android-developers.googleblog.com/2009/09/zipalign-easy-optimization.html?m=1

0
baptx On

I had the same question and did not notice why it should be used the first time I checked the documentation. But here is the part from the doc (https://developer.android.com/studio/command-line/zipalign) explaining what zipalign does, especially saying why it should be used in the second sentence (to save RAM):

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 mmap(2) , removing the need to copy this data in RAM and reducing your app's memory usage.

The doc also says signing is a different step and zipalign must be done before if you use apksigner or after if you use jarsigner.