Android Apps Expand App Size by 4GB

Android applications have typically been limited to 50MB. For most apps this is sufficient. Developers like to make every megabyte count to reduce download time. However, with more and more 3D High-de...
Android Apps Expand App Size by 4GB
Written by

Android applications have typically been limited to 50MB. For most apps this is sufficient. Developers like to make every megabyte count to reduce download time. However, with more and more 3D High-def games hitting the marketplace, Android Apps decided it was time for a change. The maximum app size for local storage has made a huge jump from 50MB to 4GB.

There is a slight catch. The size of your APK file will still have to be limited to 50MB to ensure secure on-device storage. However, you can now attach two expansion files to your APK totaling 2MB each. Android will host the apps, eliminating the need for file serving, and users will be able to see the total size of your files before purchase.

On newer devices, expansion files will automatically be downloaded, and refund time will not begin until all the files are downloaded. On older devices, the expansion files will not be downloaded until the app is used for the first time.

Developers can use the two expansion files any way they want, but Android recommends 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.

The details of how to use these new expansion files get pretty technical so I’m going to let the engineers, themselves, take it from here. The following is transcribed from the Android Developers blog:

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.

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.

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:

Expansion files are stored in shared storage. Unlike APK files, they can be read by any application.

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.

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:

  1. Include a notification UI that provides progress and estimated completion time in layouts customized for ICS and pre-ICS devices
  2. Resume large files safely
  3. Handle redirection with appropriate limits
  4. Run in the background as a service
  5. Pause and resume downloads when WiFi is not available

Get the WebProNews newsletter delivered to your inbox

Get the free daily newsletter read by decision makers

Subscribe
Advertise with Us

Ready to get started?

Get our media kit

Advertise with Us