Android Multidex and the Dex Method Limit Enabling Multidex

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

In order to enable a multidex configuration you need:

  • to change your Gradle build configuration
  • to use a MultiDexApplication or enable the MultiDex in your Application class

Gradle configuration

In app/build.gradle add these parts:

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 24
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

Enable MultiDex in your Application

Then proceed with one of three options:

When these configuration settings are added to an app, the Android build tools construct a primary dex (classes.dex) and supporting (classes2.dex, classes3.dex) as needed.
The build system will then package them into an APK file for distribution.



Got any Android Question?