• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            大龍的博客

            常用鏈接

            統(tǒng)計(jì)

            最新評(píng)論

            Zipalign: an Easy Optimization --- 轉(zhuǎn)

            The Android SDK includes a tool called zipalign that optimizes the way an application is packaged. Running zipalign against your application enables Android to interact it more efficiently at run time and thus has the potential to make it and the overall system run faster. We strongly encourage you to use zipalign on both new and already published applications and to make the optimized version available — even if your application targets a previous version of Android. This article describes how zipalign helps performance and how to use it to optimize your app.
            Zipalign工具用于優(yōu)化Android打包的應(yīng)用.zipalign作用于你的應(yīng)用可以使Android應(yīng)用更有效率.強(qiáng)烈推薦使用zipalign優(yōu)化所有的Android應(yīng)用.本文討論zipalign如何提升應(yīng)用性能.

            In Android, data files stored in each application's apk are accessed by multiple processes: the installer reads the manifest to handle the permissions associated with that application; the Home application reads resources to get the application's name and icon; the system server reads resources for a variety of reasons (e.g. to display that application's notifications); and last but not least, the resource files are obviously used by the application itself.
            Android中存儲(chǔ)在應(yīng)用中的數(shù)據(jù)文件可以被多種應(yīng)用訪(fǎng)問(wèn): 比如安裝器讀取manifest來(lái)處理應(yīng)用相關(guān)的權(quán)限; Home應(yīng)用可獲取應(yīng)用的名稱(chēng)和圖標(biāo); 系統(tǒng)服務(wù)器也會(huì)讀取資源(如,用于顯示應(yīng)用提示); 當(dāng)然這些資源也會(huì)被自身應(yīng)用使用.

            The resource-handling code in Android can efficiently access resources when they're aligned on 4-byte boundaries by memory-mapping them. But for resources that are not aligned (that is, when zipalign hasn't been run on an apk), it has to fall back to explicitly reading them — which is slower and consumes additional memory.
            當(dāng)資源通過(guò)內(nèi)存映射以4字節(jié)邊界對(duì)齊后,處理資源的代碼可以更加有效地訪(fǎng)問(wèn)到資源.但是對(duì)于那些沒(méi)對(duì)齊的資源(即使用zipalign優(yōu)化的應(yīng)用),相對(duì)來(lái)說(shuō)效率會(huì)低一些.

            For an application developer, this fallback mechanism is very convenient. It provides a lot of flexibility by allowing for several different development methods, including those that don't include aligning resources as part of their normal flow.
            對(duì)于應(yīng)用開(kāi)發(fā)者而言,這種落后機(jī)制(即未aligned的應(yīng)用)是很方便的.

            Unfortunately, for users the situation is reversed — reading resources from unaligned apks is slow and takes a lot of memory. In the best case, the only visible result is that both the Home application and the unaligned application launch slower than they otherwise should. In the worst case, installing several applications with unaligned resources increases memory pressure, thus causing the system to thrash around by having to constantly start and kill processes. The user ends up with a slow device with a poor battery life.
            不幸的是,對(duì)于用戶(hù)來(lái)說(shuō)正好相反 —— 讀取unaligned的應(yīng)用會(huì)很慢并且會(huì)占用很多內(nèi)存. 這可能導(dǎo)玩致Home應(yīng)用和unalignedy應(yīng)用運(yùn)行緩慢,甚至安裝好幾個(gè)unaligned的應(yīng)用會(huì)占用大量?jī)?nèi)存導(dǎo)致系統(tǒng)內(nèi)存不足自動(dòng)清理掉其它進(jìn) 程.這會(huì)降低將電池周期.

            Luckily, it's very easy for you to align the resources in your application:
            消除以下問(wèn)題的方案是easy的:

            1).Using ADT:  —— 使用ADT工具自動(dòng)完成以上操作
            The ADT plugin for Eclipse (starting from version 0.9.3) will automatically align release application packages if the export wizard is used to create them. To use the wizard, right click the project and choose "Android Tools" > "Export Signed Application Package..." It can also be accessed from the first page of the AndroidManifest.xml editor.

            2).Using Ant: —— 使用Ant(沒(méi)用過(guò),不清楚)
            The Ant build script (starting from Android 1.6) can align application packages. Targets for older versions of the Android platform are not aligned by the Ant build script and need to be manually aligned.
            Starting from the Android 1.6 SDK, Ant aligns and signs packages automatically, when building in debug mode.
            In release mode, Ant aligns packages only if it has enough information to sign the packages, since aligning has to happen after signing. In order to be able to sign packages, and therefore to align them, Ant needs to know the location of the keystore and the name of the key in ant.properties. The name of the properties are key.store and key.alias respectively. If those properties are present, the signing tool will prompt to enter the store/key passwords during the build, and the script will sign and then align the apk file. If the properties are missing, the release package will not be signed, and therefore will not get aligned either.

            ********************推薦方式********************
            3).Manually: —— 手動(dòng)完成align操作,使用以下命令完成aligned操作 
            In order to manually align a package, zipalign is in the tools/ folder of Android 1.6 and later SDKs. You can use it to align application packages targeting any version of Android. You should run it only after signing the apk file, using the following command: 

                zipalign -v 4 source.apk destination.apk

            4).Verifying alignment: —— 驗(yàn)證alignment
            The following command verifies that a package is aligned:

                zipalign -c -v 4 application.apk

            We encourage you manually run zipalign on your currently published applications and to make the newly aligned versions available to users. Also, don't forget to align any new applications going forward!
            推薦通過(guò)手動(dòng)方式來(lái)運(yùn)行zipalign.

            posted on 2012-10-30 20:00 大龍 閱讀(510) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            99久久国语露脸精品国产| 热re99久久6国产精品免费| 久久久免费观成人影院| 久久久受www免费人成| 久久久久亚洲精品日久生情| 久久久精品2019免费观看| 伊人久久综在合线亚洲2019| 性高朝久久久久久久久久| 亚洲人成伊人成综合网久久久| 久久精品国产亚洲网站| 亚洲国产成人精品女人久久久| 久久久久亚洲精品天堂| 精品无码久久久久久久动漫| 亚洲AV日韩精品久久久久久| 久久久久亚洲AV成人网人人网站| 欧洲精品久久久av无码电影| 久久天天躁狠狠躁夜夜av浪潮| 国产亚洲综合久久系列| 香蕉久久久久久狠狠色| 国产精品免费久久| 精品久久久噜噜噜久久久| 久久强奷乱码老熟女网站| 久久精品国产亚洲AV不卡| 成人免费网站久久久| 久久夜色精品国产噜噜噜亚洲AV| 久久综合一区二区无码| 国内精品伊人久久久久影院对白 | 777久久精品一区二区三区无码| 欧美与黑人午夜性猛交久久久 | 99久久精品毛片免费播放| 久久久国产视频| 一级a性色生活片久久无| 久久久久国产亚洲AV麻豆| 国产叼嘿久久精品久久| 99久久久精品免费观看国产| 精品免费久久久久久久| 久久精品午夜一区二区福利| 精品久久8x国产免费观看| 97久久精品人妻人人搡人人玩| 2021精品国产综合久久| 99久久精品毛片免费播放|