Android Gradle : multiDexEnabled property

Android Gradle : multiDexEnabled property

Android Build Error

Error:Execution failed for task ‘:app:transformClassesWithDexForDebug’.
> java.util.concurrent.ExecutionException: method ID not in [0, 0xffff]: 65536

Solution: Add the following multiDex property in your build.gradle.
multiDexEnabled true
so your build.gradle looks like follows


apply plugin: ''

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId ""
        minSdkVersion 11
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner ""
        multiDexEnabled true
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('', {
        exclude group: '', module: 'support-annotations'
    compile ''
    testCompile 'junit:junit:4.12'
    compile project(path: ':dhilib')

What is  multiDexEnabled true ? Why it is required ?

As per the documentation from Google, As the Android platform has continued to grow, so has the size of Android apps. When your app and the libraries it references reach a certain size, you encounter build errors that indicate your app has reached a limit of the Android app build architecture.

About the 64K reference limit

(APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. 

The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536—including Android framework methods, library methods, and methods in your own code. In the context of computer science, the term Kilo, K, denotes 1024 (or 2^10). Because 65,536 is equal to 64 X 1024, this limit is referred to as the ’64K reference limit’.

Reference :