Android Studio

Android Studio – Integrate APK Expansion Files

This article intents to clarify the process of integration of the Android APK Expansion Library with Android Studio.

Following the original documentation on how to integrate the Android APK Expansion library, and wasting time to investigate why the explained steps don’t work, provoked us to write this article.


In this example we are using the following versions:

Android Studio:  2.2 RC
Android SDK Platform: 24

I. Pre requires and file locations

First, you need to install the Android SDK

To integrate APK Expansion library, you need to import 3 libraries from your local Android SDK:

  1. play_licensing/library
  2. downloader_library
  3. zip_file
Required Libraries

The libraries are located in:


II. Import Libraries in Android Studio

Before you begin, you need to change the following line in the Android SDK downloader_library file:

Change line

Since the downloader_library depends on the play_licensing library, we must change the reference parameter to point to the correct directory.

Obviously, Android SDK has changed the name of the play_licensing library on some point without changing the reference in the properties file.

Now you can import the required libraries in your Android Studio IDE:

Open Android Studio (and your project respectively) and click on Import Module… ( File -> New -> Import Module… )

Import new module menu

Then, from the open window, type the path to the library you want to import. E.g:


Then click Next and leave all check-boxes as are. Then finish the operation.

Hint: If you import the downloader library first, the licensing library will be imported automatically  as well.

Repeat this step for zip_file library as well.

New Module window

Now, the Android APK Expansion library should be imported correctly.

In your project, the imported libraries should appears like this:

Imported modules

Next: Do not forget to add these libraries in your project dependencies:

Add module dependencies

III. Additional issues

In case your build failed with some of the following exceptions

Error:(23, 23) error: cannot find symbol class Header

Add in your file (including these of the libraries), the following line:

useLibrary 'org.apache.http.legacy'

This line must be added in android {….} block. E.g:

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.1'
    useLibrary  'org.apache.http.legacy'

Also, copy org.apache.http.legacy.jar in your apps lib folder. This file is located in:

/your SDK directory/platforms/android-XX/optional/org.apache.http.legacy.jar

Then, add this file as a library (right click on the jar file -> Add as library)

Putting org.apache.http.legacy.jar in your local lib folder causes Multiple dex files define exception when building your app.

Error: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { }

This is a known bug.
In change from this:

boolean bindResult = mContext.bindService(new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))),
                                          this, // ServiceConnection.

to this:

boolean bindResult = mContext.bindService(new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")))
                                    this, // ServiceConnection.

We are not going to dive into the usage/functionality of these libraries.

Details about how to integrate and use the APK Expansion Library, you can find in the original Google Android Development documentation.

Your Comments are Welcome!