So today, we’re expanding the Android app size limit to 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.
- Each app can have two expansion files, each one up to 2GB, in whatever format you choose.
- Android Market will host the files to save you the hassle and cost of file serving.
- Users will see the total size of your app and all of the downloads before they install/purchase.
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.
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.- 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.
- 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.
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:Location:Expansion files are stored in shared storage. Unlike APK files, they can be read by any application.<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
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. 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
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.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
- Resume large files safely
- Handle redirection with appropriate limits
- Run in the background as a service
- Pause and resume downloads when WiFi is not available
[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.]
☛ El artículo completo original de Tim Bray lo puedes ver aquí

No hay comentarios.:
Publicar un comentario