APK Expansion Files

From Gideros Wiki
Jump to: navigation, search

Google Play currently requires that your APK file be no more than 50MB. For most applications, this is plenty of space for all the application's code and assets. However, some apps need more space for high-fidelity graphics, media files, or other large assets. Previously, if your app exceeded 50MB, you had to host and download the additional resources yourself when the user opens the app. Hosting and serving the extra files can be costly, and the user experience is often less than ideal. To make this process easier for you and more pleasant for users, Google Play allows you to attach two large expansion files that supplement your APK.

Gideros supports APK Expansion files starting from the version 2012.09.6.

Preparing APK Expansion Files

  1. Export your Eclipse project.
  2. After exporting, assets/asserts directory contains all the code and asset files.
  3. Goto to the assets/assets folder, select the big files and directories and create create an uncompressed .zip file from them. If the assets/assets folder contains bigFile.png, the .zip should contain bigFile.png (and not assets/assets/bigFile.png or assets/bigFile.png). To create an uncompressed zip file, you should select the compression method as store.
  4. Delete these compressed big files and directories
  5. Move the created .zip file outside of the project directory. This is our main APK expansion file.
  6. Export your project as Android application. And this is our APK.

Testing APK Expansion Files

One way to test your APK expansion file is uploading your APK and main expansion file to Google Play and after it's available, install from Google Play. But this is a time consuming way. Other possibility is renaming the expansion file and putting it to the correct directory.

Regardless of the file type, Google Play considers them opaque binary blobs and renames the files using the following scheme:


For example, suppose your APK version is 2 and your package name is com.example.app. If you upload a main expansion file, the file is renamed to:


When Google Play downloads your expansion files to a device, it saves them to the system's shared storage location. The specific location for your expansion files is:


According to the previous example, main expansion file should be placed at:


Main and Patch Expansion Files

Each time you upload an APK using the Google Play Android Developer Console, you have the option to add one or two expansion files to the APK. Conceptually, each expansion file plays a different role:

  • The main expansion file is the primary expansion file for additional resources required by your application.
  • The patch expansion file is optional and intended for small updates to the main expansion file.

While you can use the two expansion files any way you wish, we recommend that the main expansion file deliver the primary assets and should rarely if ever updated; the patch expansion file should be smaller and serve as a "patch carrier," getting updated with each major release or as necessary.

When a file needs to be loaded from the resource directory, it's first looked at patch expansion file (if exists) and then main expansion file (if exists) and then APK.