Android apk Optimization Tools zipalign detailed _android

Source: Internet
Author: User
Tags documentation

The Android SDK contains a new tool zipalign for optimizing apk. It improves the efficiency of the optimized applications with the Android system (saying: "Get rich first, build a road", and the Android team has a new highway between applications and Android) Thus can make the whole system running speed has a big promotion. The Android team strongly recommends that developers use zipalign optimization tools before releasing new apps, and that apps with optimized APK is recommended to replace the existing version for those that have been released but not limited to the system version.

Zipalign is described in the following sections from three aspects:

1, zipalign how to optimize

2. How to use Zipalign

3, the use of zipalign reasons

According to the official documentation, the application data in the Android system is stored in its apk file and can be accessed by multiple processes, and the installation process includes the following steps:

1. Installer obtains the permissions information associated with the current application through each APK manifest file.

2, home application read the current APK name and icon and other information.

3. System server will read some information related to application operations, such as obtaining and processing application notifications requests.

4. Finally, the content contained in the APK is not limited to the current application, but can be invoked by other application to improve the reusability of the system resources.

Zipalign optimization is the most fundamental purpose is to help the operating system more efficient based on the request index resources, the Resource-handling code unified data Structure alignment (data structure alignment standard: DSA) limited to 4-byte Boundaries. If the first contact with the content of the data structurealignment, it is highly recommended to search for more relevant content to fully understand the ultimate purpose of this, which is the key to understanding the zipalign work principle. Without the alignment criteria, the processor cannot accurately and quickly locate related resources in the memory address.

The current system uses the fallbackmechanism mechanism to deal with applications that do not apply DSA standards, which is a great convenience for ordinary developers without having to focus on cumbersome memory manipulation issues. But on the contrary, for such an application will bring some trouble to ordinary users, not only affect the efficiency of the operation of the program, but also the overall efficiency of the system down and occupy a large number of unnecessary memory resources, or even consume a certain amount of battery resources (battery life).

The Android SDK provides three ways to apply align operations:

1, the use of ADT:

Starting with the ADT version 0.9.3, align operations can be automatically performed on the published Applicationpackages through the Export Wizard. Set method: Right-click Project, then choose "Android Tools" > "exportsigned application Package ...". Or you can set it directly in Androidmanifest.xml.

2. Use ant:

Application packages with API level greater than or equal to 4 can align optimizations directly through the ant build script. However, for the API level less than 4, only manual align optimizations can be taken.

The Align optimization is performed automatically when the Ant build script runs debug packages (API level >= 4) by default.

For release packages. When using the ant build script to perform align optimizations, you first need to have enough information to sign packages. Align optimizations can be performed after the signing is completed. Learn how to sign Packages through official documentation.

3, manual implementation of align Optimization:

Use the Tools folder under the Zipalign tool. First pull up the cmd command line, and then execute: ZIPALIGN-V 4 source.apk androidres.apk. This method is not limited by API level and can perform align optimizations for any version of APK.

You can also use the Zipalign tool to check whether the current apk has performed align optimizations. Command: Zipalign-c-V 4 androidres.apk

Once again remind the developer to apply the Zipalign tool to force the optimization of the released application packages and let your users use the latest version.

Related Article

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.