把 XE8 裝起來後,除了先看 What's New 之外,還是不免俗的想要關心一下 XE8 編譯出來的 apk 大小,話說 apk size 不是那麼重要了不是嗎?

測試案例還是沿用之前的那個 app

以下是比較資料

版本 apk size classes.dex size
XE5 with Upd2 4.94 MB (5,186,751 bytes) 1.28 MB (1,343,644 bytes)
XE6 5.49 MB (5,757,687 bytes) 1.90 MB (1,999,460 bytes)
XE7 6.14 MB (6,444,201 bytes) 2.64 MB (2,773,944 bytes)
XE7 Upd1 6.15 MB (6,454,017 bytes) 2.64 MB (2,774,372 bytes)
XE8 5.87 MB (6,166,025 bytes) 2.65 MB (2,779,940 bytes)

classes.dex 持續長大中可以預期,倒是最後的 apk size 竟然減小了,這就有點令人意外了,經比較之後確認是 delphi 編譯出來的 .so 檔案變小了,是 delphi compiler 最佳化了?還是 FMX 架構更優化了?...有待進一步的研究

另外 XE8 中新增了一項設定,就是可以在 Project Manager 中指定「不需要使用」的 Java library,像下圖

把這些 jar 都 disable 掉後,編譯出來的 apk size,會從原本的 5.87 MB (6,166,025 bytes) 減小至 5.20 MB (5,456,833 bytes),app 在 android 上仍可以正常執行無誤…

雖然對於 apk size 減小有幫助,但是又有多少人會知道哪些 jar 一定要用,哪些 jar 可以選擇性使用?官方有提供相對應的文件

http://docwiki.embarcadero.com/RADStudio/XE8/en/Using_the_Built-in_RAD_Studio_Java_Libraries_for_Android

 Native FilesDescription

Android API

Androidapi.JNI.App
Androidapi.JNI.Dalvik
Androidapi.JNI.GraphicsContentViewText
Androidapi.JNI.Hardware
Androidapi.JNI.InputMethodService
Androidapi.JNI.Java.Security
Androidapi.JNI.JavaTypes
Androidapi.JNI.Location
Androidapi.JNI.Media
Androidapi.JNI.Net
Androidapi.JNI.OpenGL
Androidapi.JNI.Os
Androidapi.JNI.Provider
Androidapi.JNI.Telephony
Androidapi.JNI.Util
Androidapi.JNI.VideoView
Androidapi.JNI.Webkit
Androidapi.JNI.Widget

API of the Android platform.

Android Support

Androidapi.JNI.Support

Set of libraries that provide a wide array of different features for Android programming.

FireMonkey

Androidapi.JNI.Embarcadero

Library that provides the core functionality required by the FireMonkey Application Platform on the Android platform.

Google Mobile Ads

Androidapi.JNI.AdMob

SDK of the Google Mobile Ads service.

Google Analytics

Androidapi.JNI.Analytics

SDK of the Google Analytics service.

Google Play Application Licensing

Androidapi.JNI.Licensing

License Verification Library, a collection of helper classes to simplify adding licensing to an Android application.

Google Play In-app Billing

Androidapi.JNI.InAppBilling

API of the Google Play In-app Billing service.

Google Play Services

Androidapi.JNI.PlayServices

API of the Google Play services.

APK Expansion

Androidapi.JNI.ApkExpansion

SDK for hosting Android APK expansion files on the Google Play servers.

Cloud Messaging

Androidapi.JNI.PlayServices.GCM

SDK of the Google Cloud Messaging service.

但除非你很瞭解你自己在做什麼,否則....還是不要輕易的 disable 吧,畢竟努力了半天,減少的 size 不到 1MB...誰叫我們要用 FMX 呢...有一好沒兩好....

 

to be continued....

arrow
arrow
    文章標籤
    delphi xe8 apk size
    全站熱搜

    縹緲 發表在 痞客邦 留言(4) 人氣()