zipalign, also known as zip align, is specially designed to optimize apk
It has some meanings similar to "4K alignment".
In Android, the data files stored in each application will be accessed by multiple processes: the installer will read the application's manifest file to handle permission issues related to it; the Home application will Read resource files to obtain the application's name and icon; system services will read resources for many reasons (for example, to display the application's Notification); in addition, the application itself uses resource files.
In Android, code that accesses resource files is efficient when the resource files are aligned to 4-byte boundaries through memory mapping. However, if the resources themselves are not aligned (without using the zipalign tool), it must fall back on the old path and read them explicitly - a process that will be slow and cost extra memory.
For application developers, this explicit reading method is quite convenient. It allows for a number of different development methods, including resources that are not aligned in the normal flow, so this way of reading is very convenient.
Unfortunately for users, the opposite is true - reading resources from an unaligned apk is slower and consumes more memory. In the best case, Home programs and unaligned programs start slower than aligned ones (this is the only visible effect). In the worst case, installing some applications with unaligned resources can increase memory pressure and cause the system to repeatedly start and kill processes. Eventually, users gave up using devices that were so slow and power-hungry.
zipalign improves the interaction efficiency between optimized Applications and the Android system.
zipalign is like building a highway between Applications and the Android system
Simple optimization: zipalign
The Android SDK contains a "zipalign" tool , which can optimize packaged applications. Running zipalign on your application makes the interaction between Android and the application more efficient at runtime. Therefore, this approach makes applications and the entire system run faster. We strongly recommend using the zipalign tool on new and already released applications to get optimized versions - even if your application was developed on an older version of the Android platform. This article will describe how zipalign helps improve performance and how to use it to optimize your app.
In Android, the data files stored in each application will be accessed by multiple processes: the installer will read the application's manifest file to handle permission issues related to it; the Home application will Read resource files to obtain the name and icon of the application; system services will read resources for many reasons (for example, to display the application's Notification); in addition, the resource file is used by the application itself.
Using ADT:
The ADT plug-in in Eclipse can automatically align Release packages if you use the export wizard. Using the wizard, right-click the project properties and select "Android Tools" > "Export Signed Application Package…". Of course, you can also do it through the first page of the AndroidManifest.xml editor.
Using Ant:
The Ant compile script (starting with Android 1.6) can align packages. Versions of older platforms cannot be aligned through Ant compilation scripts and must be aligned manually.
Starting with Android 1.6, Ant automatically aligns and signs packages when compiling in Debug mode.
In Release mode, Ant will only perform the alignment operation if there is enough information to sign the package, because the alignment process occurs after signing. In order to be able to sign the package and then perform the alignment operation, Ant must know the location of the keystore and the name of the key in build.properties. The corresponding properties are named key.store and key.alias. If these properties are empty, the signing tool will prompt for the store/key password during the compilation process, and then the script will perform the signature and alignment of the apk file. If these attributes are not present, the Release package will not be signed, and naturally it will not be aligned.
Manual:
In order to manually align the package, there is a zipalign tool in the tools/ folder of the SDK of Android 1.6 and later. You can use this to align packages under any version.
You must do this after signing the apk file, use the following command: zipalign -v 4 source.apk destination.apk
Verify alignment:
The following command is used to check whether the package is Align: zipalign -c -v 4 application.apk
It is highly recommended to manually zipalign your application and ensure that the latest aligned version is provided to users. Also, don’t forget that there are new applications out there that require this too!
Simple optimization: zipalign
The Android SDK includes a "zipalign" tool, which can optimize packaged applications. Running zipalign on your application makes the interaction between Android and the application more efficient at runtime. Therefore, this approach makes applications and the entire system run faster. We strongly recommend using the zipalign tool on new and already released applications to get optimized versions - even if your application was developed on an older version of the Android platform. This article will describe how zipalign helps improve performance and how to use it to optimize your app.
In Android, the data files stored in each application will be accessed by multiple processes: the installer will read the application's manifest file to handle permission issues related to it; the Home application will Read resource files to obtain the name and icon of the application; system services will read resources for many reasons (for example, to display the application's Notification); in addition, the resource file is used by the application itself.
In short, zipalign is specially designed to optimize apk
Reference materials: Android Network "[ROM Production/Modification Tutorial] Big Bear Resource Zipalign Optimization!" Make your phone run more smoothly! ! ! 》, Baidu article