Android APK Expansion files

11 / Jan / 2015 by Noor Alam 2 comments

Google Play allows max 50 MB of APK size for any android application. But in many cases in projects where we use large number of images and media files such as sound and videos, the APK size grows beyond 50 MB limit.

Google play now provide facility of uploading two more files called “APK Expansion Files”. Each of these two files could be 2GB large and its uploading is free of cost.We can pack our image, media and other larger files in these expansion files which will be available to the application.

Each time you upload an APK using the Google Play Developer Console, you have the option to add one or two expansion files to the APK.

When user downloads the application, in most of the cases these files would be downloaded along with the apk on the external sdcard. On some devices the Expansion files is not downloaded on install time, in such cases developer must check on first launch of the application if the file is present on the external sd card else download the expansion files from the server manually and save it on the external sd card on a specific path strictly defined by the Google.

Theoretically, each expansion file plays a different role:

1. The main expansion file is the primary expansion file for additional resources required by your application. It almost never changes throughout the application life.

2. The patch expansion file is optional and intended for small updates to the main expansion file.

File name Format:                                                                                                      

Each expansion file you upload can be any format you choose ZIP, PDF, MP4 etc. Regardless of the file type, Google Play considers them opaque binary blobs and remames the file using the following scheme:


Where <expansion-version> is an integer that matches the version code (android:versionCode) of the APK with which the expansion is first associated.

For example is a main expansion file name.

Storage Location:

The specific location for your expansion files must be:



where  <shared-storage> will be equal to the value of getExternalStorageDirectory() .Both main and patch expansion files will reside in this same directory.User can read the content from a zip file even without unpacking it using Google’s APK Expansion Zip Library.

Downloading the Expansion files:

When the user launches your application, your app must check whether the expansion files are already saved on the device.

  1. If yes, your app is ready to go.
  2. If no, your app must download the expansion files over HTTP from Google Play. Your app must send a request to the Google Play client using the Google Play’s Application Licensing service, which responds with the name, file size, and URL for each expansion file. With this information, you then download the files and save them to the proper storage location.

To simplify downloading work for you, Google have built a Downloader Library, which requests the expansion file URLs through the licensing service, downloads the expansion files, performs all of the tasks , and even allows your activity to pause and resume the download. By adding the Downloader Library and a few code hooks to your application, almost all the work to download the expansion files is already coded for you.

Rules and Limitations:

  1. Each expansion file can be no more than 2GB.
  2. In order to download your expansion files from Google Play, the user must have acquired your application from Google Play. Google Play will not provide the URLs for your expansion files if the application was installed by other means.
  3. When performing the download from within your application, the URL that Google Play provides for each file is unique for every download and each one expires shortly after it is given to your application.
  4. If you update your application with a new APK or upload multiple APKs for the same application, you can select expansion files that you’ve uploaded for a previous APK. The expansion file’s name does not change—it retains the version received by the APK to which the file was originally associated.
  5. If you use expansion files in combination with multiple APKs in order to provide different expansion files for different devices, you still must upload separate APKs for each device in order to provide a unique  versionCode value  and declare different filters for each APK.
  6. You cannot issue an update to your application by changing the expansion files alone—you must upload a new APK to update your app. If your changes only concern the assets in your expansion files, you can update your APK simply by changing the versionCode (and perhaps also the versionName).
  7. Do not save other data into your obb/ directory. If you must unpack some data, save it into the location specified by getExternalFilesDir().
  8. Do not delete or rename the .obb expansion file (unless you’re performing an update). Doing so will cause Google Play (or your app itself) to repeatedly download the expansion file.
  9. When updating an expansion file manually, you must delete the previous expansion file.


For full implementation details please visit the Google’s official developer website on the following links:

1. APK Expansion files

2. Use and attach APK Expansion files


Thanks for Reading:

Noor Alam                                                                                                                                       


comments (2)

Leave a Reply

Your email address will not be published. Required fields are marked *