Add Multidex to your Android Application

If your Android game has surpassed the 64K method limit, you'll need to look into implementing Multidex, ProGuard or both. While ProGuard can reduce the number of methods in your application, Multidexing will split your binary in order to allow more than 64K methods.

If you haven't tried enabling ProGuard, we recommend trying that out first before enabling Multidex. You can read more about adding ProGuard to your application and its benefits in this article. If you've implemented ProGuard, and are still over the 64K method limit, then you should follow the instructions here in order to implement Multidex. 

You can follow these steps in order to enable Multidex:

  1. Make sure that you are on at least Android SDK Build Tools 21.1
  2. On your build.gradle file (module level), enable Multidex by adding 'multiDexEnabled true' to your defaultConfig block.
  3. Also inside build.gradle, add multidex as a dependency:
    compile 'com.android.support:multidex:1.0.0'
  4. In your manifest, add the MultiDexApplication class as shown below
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   
package="com.example.android.multidex.myapplication">
   
<application
        ...
       
android:name="android.support.multidex.MultiDexApplication">
        ...
   
</application>
</manifest>

When you are able to perform these steps correctly, Android build tools will create a primary DEX and support DEX files as needed. If you want to learn more about Multidex, we recommend reading this article on Android Studio.

If you have other questions that were not covered by this article, feel free to reach out to us at integrations@skillz.com