Android app zipalign-how to make Android apps run more efficiently

Source: Internet
Author: User
Tags zip folder

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.