Android Apps Break the 50MB Barrier
Android applications have historically been limited to a maximum
size of 50MB. This works for most apps, and smaller is usually
better — every megabyte you add makes it harder for your users to
download and get started. However, some types of apps, like high-quality
3D interactive games, require more local resources.
Android app先前將最大檔案容量限制在50MB,這個方案在許多的App上運作的很好 - 因為你所編譯並產出的每megabyte都會讓你的使用者需要花時間下載後才能啟動。然而,有一些類型的App,像是高畫質的3D互動遊戲,卻需要更大量的本地端資源。
So today, we’re expanding the Android app size limit to 4GB.
因此,我們今天將Android App的容量限制提高至4GB。
The
size of your APK file will still be limited to 50MB to ensure secure
on-device storage, but you can now attach expansion files to your APK.
APK檔容量其實仍然限制在50MB,這是為了確保裝置儲存的安全性。但是你現在還可以添加擴充檔至您的APK中。 - Each app can have two expansion files, each one up to 2GB, in whatever format you choose.每個App有2個擴充檔,每一個擴充檔最高是2GB,沒有檔案格式上的限制。
- Android Market will host the files to save you the hassle and cost of file serving.Android市集會將這2個充檔保留在Android Server中,一方面省去了你開發上的麻煩,也節省你的開發成本。
- Users will see the total size of your app and all of the downloads before they install/purchase.使用者會在他們安裝/購買前,看到你App的總量和總下載次數。
On
most newer devices, when users download your app from Android Market,
the expansion files will be downloaded automatically, and the refund
period won’t start until the entire download completes. On older
devices, your app will download the expansion files the first time it
runs, via a downloader library which we’ve provided below.
在大多數新型裝置中,當使用者從Android市集下載了您的App,擴充檔也會跟著被自動下載,此時,15分鐘的退費期間將不會被算在內,15分鐘的限制將會在全部的檔案都下載完成後才會開始計算。然而,在一些舊有的裝置中,你的App會在下載並執行App的第1次啟動後,才開始透過我們底下提供的downloader函式庫下載擴充檔。
While
you can use the two expansion files any way you wish, we recommend that
one serve as the initial download and be rarely if ever updated; the
second can be smaller and serve as a “patch carrier,” getting versioned
with each major release.
雖然您可以依照你希望的方式來使用這2個擴充檔,我們仍建議您將其中一個擴充檔用在初始化下載,若是要更新App,盡量不要用它。另一個擴充槽則可設計成被置放較小的檔案,提供"更新補丁(patch carrier)",用來做每個版本主要更新的內容。Helpful Resources有用的資源
In order to
make expansion file downloading as easy as possible for developers,
we're providing sample code and libraries in the Android SDK Manager.
為了能簡單且有效的讓開發者使用擴充檔這個資源,我們在Android SDK Manager提供了簡單的範例程式和函式庫。 - In the Google Market Licensing package, an updated License Verification Library (LVL). This minor update mostly adds the ability to obtain expansion file details from the licensing server.在Google市集的許可套件中,一個更新的許可驗証函式庫(LVL)。能過這個小更新取得擴充檔的詳細資訊。
- From the Google Market APK Expansion package, the downloader service example. The library makes it relatively simple to implement a downloader service in your application that follows many of our best practices, including resuming downloads and displaying a progress notification.從Google市集APK擴充套件來的downloader服務範例。函式庫非常容易從downloader服務去實作,因為這是從我們很多很棒的實作中去完成的 - 功能包含了續傳下載和訊息通知欄的下載進度顯示。
Because
many developers may not be used to working with one or two large files
for all of their secondary content, the example code also includes
support for using a Zip file as the secondary file. The Zip example
implements a reasonable patching strategy that allows for the main
expansion file to “patch” the APK and the patch file to “patch” both the
APK and the main expansion file by searching for asset files in all
three places, in the order patch->main->APK.
由於許多的開發者也許不會用他們次要的擴充檔來放置1~2個大型檔案,因此範例程式用zip格式來做次要檔的放置。zip範例的實作是合理的策略,允許主要的擴充檔以"patch" APK的方式來擴充,(恕刪)...........順序是ptch-->main-->APK。Expansion File Basics擴充檔基本概念
Expansion
files have a specific naming convention and are located in a specific
place for each app. As expansion files are uploaded to the publisher
site, they are assigned a version code based upon the version of the APK
that they are associated with. The naming convention and location are
as follows:
擴充檔在每一個app中,都擁有特定的命名慣例和置放的位置。擴充檔被更新至publisher網站,也被指定到相關連的某個version code以上的apk中。命名慣例和位置依照︰Location:<shared-storage>/Android/obb/<package-name>/
Filename:[main|patch].<expansion-version>.<package-name>.obb
Example:/sdcard/Android/obb/com.example.myapp/main.5.com.example.myapp.obb
Expansion files are stored in shared storage. Unlike APK files, they can be read by any application.
擴充檔被儲存在分享空間。它們不像APK檔,因此可以被任何的APP自由的讀取。Downloading and Using the Expansion Files下載並使用擴充檔
When
the primary activity for the app is created, it should check to make
sure the expansion files are available. The downloader library provides
helper functions (for example the “Helpers” class in the code below) to
make this easy.
當主要activity被建立後,應該要檢查並確保是否有可用的擴充檔。downloader函式庫提供了一個helper功能(範例程式中被命名為"Helper"類,下方的程式中也可看到),讓開發者方便使用。boolean expansionFilesDelivered() {
// get filename where main == true and version == 3
String fileName = Helpers.getExpansionAPKFileName(this, true, 3);
// does the file exist with FILE_SIZE?
if (!Helpers.doesFileExist(this, fileName, FILE_SIZE, false))
return false;
}
return true;
}
}
If the file does not exist, fire up the downloader service with
如果擴充檔沒有放在SD卡的指定位置,可以使用DownloaderClientMarshaller.startDownloadServiceIfRequired()
.
The downloader will perform an LVL check against the server. This
check will deliver the names of the files, file sizes, and the file
URLs.DownloaderClientMarshaller.startDownloadServiceIfRequired()來
啟動downloader服務。downloader會針對server執行LVL檢驗,檢驗會傳遞檔案名稱、檔案大小和檔案的URLs。
Once that check has been completed, it will begin
downloading the files. You don’t have to use our download solution, but
you might want to because we:
一旦檢查機制完成,就會開始下載檔案。也許你不需要使用我們提供的下載方案,但是您可能還是會用到,因為我們提供了︰- Include a notification UI that provides progress and estimated completion time in layouts customized for ICS and pre-ICS devices訊息通知介面,能在ICS和ICS版本之前的裝置提供了進度條和下載時間估算。
- Resume large files safely提供安全性的續傳檔案。
- Handle redirection with appropriate limits重新定位apk的適量限制。
- Run in the background as a service提供背景服務下載。
- Pause and resume downloads when WiFi is not available當WiFi失效時,提供暫停和續傳的功能。
Enjoy!
We can’t wait to see what kinds of things developers do with this! For
more information about how to use expansion files with your app, read
the APK Expansion Files developer guide.
好好享用吧!我們迫不及待想看到開發者使用這些功能!更多擴充檔的資訊,請閱讀開發者導引的APK Expansion Files單元。[This post wasn’t actually written by anyone, but bashed out by a posse of engineering and product-management people. Heavy bashers included Dan Galpin, Ilya Firman, Andy Stadler, Michael Siliski, and Ellie Powers.]
您好,我現在有個超過50M的apk
ReplyDelete準備上架
看了您本篇的說明還是苦手
請問能盡量白話一點讓我按步驟執行嗎?
感激不盡