The android SDK contains a tool named zipalign that can be used to optimize the APK package.
We know that APK is actually a zip compressed file. zipalign can make your application run faster. The principle is to increase the system resolution speed by formatting the sequence of binary files in the ZIP folder. Just like formatting the code before reading it, it makes it easier for us to understand its meaning.
On the Android platform, data files are stored in the APK file and can be accessed by multiple processes. If you have developed Win32, you may know the granularity alignment problem of the program. It is good, although it is not a PE file, like in zip, resource access can be optimized through better optimization, while zipalign uses a 4-byte boundary alignment to mirror memory and improve execution efficiency by changing the space for time.
The following is an example of zipalign:
Zipalign is located in the tools folder of the android SDK. If you use the Windows operating system, run it in cmd:
The complete command line description is
E: \ Android-SDK-Windows \ tools> zipalign.exe zip Alignment utility
Copyright (c) 2009 the android open source project
Usage: zipalign [-F] [-v] <align> infile.zip outfile.zip
Zipalign-C [-v] <align> infile.zip
<Align>: alignment in bytes, e.g. '4' provides 32-bit alignment
-C: Check alignment only (does not modify file)
-F: overwrite existing outfile.zip
-V: verbose output
|
Zipalign-V 4 source.apk destination.apk is simple to use. Here,-V indicates the detailed output, and 4 indicates that the alignment is 4 bytes. If the-F parameter is added, the existing output file will be overwritten.
You can use zipalign-C-V 4 destination.apk to check whether your APK file is successfully optimized. Here, the-C parameter indicates checking alignment and can be viewed as read-only execution, finally, we are prompted that this step may cause file signature problems. Pay attention to the order in which the APK signature is executed.
Finally, the optimization is necessary. The latest Android SDK does not automatically complete this step.