Zipalign: a straightforward optimization


Notice: Undefined variable: postids in /home/oflappsx/public_html/wp-content/themes/bloggingpro/inc/template-tags.php on line 580


The Android 1.6 SDK features a instrument referred to as zipalign that optimizes the way in which an software is packaged. Doing this allows Android to work together together with your software extra effectively and thus has the potential to make your software and the general system run sooner. We strongly encourage you to make use of zipalign on each new and already printed functions and to make the optimized model accessible—even when your software targets a earlier model of Android. We’ll get into extra element on what zipalign does, how you can use it, and why you will need to achieve this in the remainder of this put up.

In Android, knowledge information saved in every software’s apk are accessed by a number of processes: the installer reads the manifest to deal with the permissions related to that software; the Dwelling software reads sources to get the applying’s title and icon; the system server reads sources for quite a lot of causes (e.g. to show that software’s notifications); and final however not least, the useful resource information are clearly utilized by the applying itself.

The resource-handling code in Android can effectively entry sources once they’re aligned on 4-byte boundaries by memory-mapping them. However for sources that aren’t aligned (i.e. when zipalign hasn’t been run on an apk), it has to fall again to explicitly studying them—which is slower and consumes further reminiscence.

For an software developer such as you, this fallback mechanism may be very handy. It offers a whole lot of flexibility by permitting for a number of totally different improvement strategies, together with people who do not embrace aligning sources as a part of their regular circulate.

Sadly, the scenario is reversed for customers—studying sources from unaligned apks is gradual and takes a whole lot of reminiscence. In the perfect case, the one seen result’s that each the Dwelling software and the unaligned software launch slower than they in any other case ought to. Within the worst case, putting in a number of functions with unaligned sources will increase reminiscence stress, thus inflicting the system to thrash round by having to continually begin and kill processes. The person finally ends up with a gradual system with a poor battery life.

Fortunately, it is very simple to align the sources:

  • Utilizing ADT:
    • ADT (beginning with 0.9.3) will robotically align launch software packages if the export wizard is used to create them. To make use of the wizard, proper click on the mission and select “Android Instruments” > “Export Signed Utility Bundle…” It can be accessed from the primary web page of the AndroidManifest.xml editor.
  • Utilizing Ant:
    • The Ant construct script that targets Android 1.6 (API degree 4) can align software packages. Targets for older variations of the Android platform are usually not aligned by the Ant construct script and should be manually aligned.
    • Debug packages constructed with Ant for Android 1.6 functions are aligned and signed by default.
    • Launch packages are aligned robotically provided that Ant has sufficient info to signal the packages, since aligning has to occur after signing. So as to have the ability to signal packages, and due to this fact to align them, Ant must know the situation of the keystore and the title of the important thing in construct.properties. The title of the properties are key.retailer and key.alias respectively. If these properties are current, the signing instrument will immediate to enter the shop/key passwords throughout the construct, and the script will signal after which align the apk file. If the properties are lacking, the discharge package deal won’t be signed, and due to this fact won’t get aligned both.
  • Manually:
    • With the intention to manually align a package deal, zipalign is within the instruments folder of the Android 1.6 SDK. It may be used on software packages concentrating on any model of Android. It ought to be run after signing the apk file, utilizing the next command:
      zipalign -v 4 supply.apk vacation spot.apk
  • Verifying alignment:
    • The next command verifies {that a} package deal is aligned:
      zipalign -c -v 4 software.apk

We encourage you manually run zipalign in your presently printed functions and to make the newly aligned variations accessible to customers. And remember to align any new functions going ahead!





oflapps.xyz


Notice: Undefined variable: postids in /home/oflappsx/public_html/wp-content/themes/bloggingpro/inc/template-tags.php on line 427

Leave a Reply

Your email address will not be published. Required fields are marked *