把 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 可以選擇性使用?官方有提供相對應的文件
Native Files | Description | |
---|---|---|
|
API of the Android platform. | |
|
Set of libraries that provide a wide array of different features for Android programming. | |
|
Library that provides the core functionality required by the FireMonkey Application Platform on the Android platform. | |
|
SDK of the Google Mobile Ads service. | |
|
SDK of the Google Analytics service. | |
|
License Verification Library, a collection of helper classes to simplify adding licensing to an Android application. | |
|
API of the Google Play In-app Billing service. | |
|
API of the Google Play services. | |
|
SDK for hosting Android APK expansion files on the Google Play servers. | |
|
SDK of the Google Cloud Messaging service. |
但除非你很瞭解你自己在做什麼,否則....還是不要輕易的 disable 吧,畢竟努力了半天,減少的 size 不到 1MB...誰叫我們要用 FMX 呢...有一好沒兩好....
to be continued....