• <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>

            大龍的博客

            常用鏈接

            統計

            最新評論

            Zipalign: an Easy Optimization --- 轉

            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工具用于優化Android打包的應用.zipalign作用于你的應用可以使Android應用更有效率.強烈推薦使用zipalign優化所有的Android應用.本文討論zipalign如何提升應用性能.

            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中存儲在應用中的數據文件可以被多種應用訪問: 比如安裝器讀取manifest來處理應用相關的權限; Home應用可獲取應用的名稱和圖標; 系統服務器也會讀取資源(如,用于顯示應用提示); 當然這些資源也會被自身應用使用.

            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.
            當資源通過內存映射以4字節邊界對齊后,處理資源的代碼可以更加有效地訪問到資源.但是對于那些沒對齊的資源(即使用zipalign優化的應用),相對來說效率會低一些.

            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.
            對于應用開發者而言,這種落后機制(即未aligned的應用)是很方便的.

            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.
            不幸的是,對于用戶來說正好相反 —— 讀取unaligned的應用會很慢并且會占用很多內存. 這可能導玩致Home應用和unalignedy應用運行緩慢,甚至安裝好幾個unaligned的應用會占用大量內存導致系統內存不足自動清理掉其它進 程.這會降低將電池周期.

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

            1).Using ADT:  —— 使用ADT工具自動完成以上操作
            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(沒用過,不清楚)
            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: —— 手動完成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: —— 驗證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!
            推薦通過手動方式來運行zipalign.

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

            国产美女久久精品香蕉69| 成人妇女免费播放久久久| 国内精品久久人妻互换| 日韩十八禁一区二区久久 | 久久久青草久久久青草| 亚洲综合熟女久久久30p| 狠狠精品久久久无码中文字幕| 伊人伊成久久人综合网777| 久久综合给合综合久久| 一级做a爰片久久毛片看看| 亚洲七七久久精品中文国产| 最新久久免费视频| 99久久国产综合精品女同图片 | 久久99热国产这有精品| 久久久久久九九99精品| 国产精品久久自在自线观看| 亚洲伊人久久大香线蕉苏妲己| 9999国产精品欧美久久久久久| 国产一区二区三精品久久久无广告| 久久久久亚洲AV综合波多野结衣| 久久久久无码中| 日韩人妻无码精品久久免费一| 久久久久久久久无码精品亚洲日韩| 国产精品久久久久久福利69堂| 国产精品内射久久久久欢欢 | 亚洲狠狠综合久久| 伊人久久精品影院| www.久久热.com| 欧美久久一级内射wwwwww.| 香蕉久久av一区二区三区| 久久久久夜夜夜精品国产| 久久这里有精品| 久久99国产精品久久99| 久久久久久亚洲精品不卡 | 四虎影视久久久免费观看| 午夜人妻久久久久久久久| 国产精品久久久久久久| 一本色道久久88综合日韩精品 | 久久精品国产亚洲av麻豆图片 | 日韩中文久久| 国内精品久久久久久久影视麻豆|