Search code examples
androidandroid-studioandengineandroid-multidex

UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536


I have below dependencies in my Gradle file :

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "packagename"
        minSdkVersion 10
        targetSdkVersion 23
    }

    sourceSets {
        main {
            jni.srcDirs = []
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:23.0.1'
    compile files('libs/FLurry_3.2.2.jar')
    compile files('libs/pixel-perfect-collision.jar')
    compile files('libs/twitter4j-core-3.0.3.jar')
    compile project(':zip_file')
    compile project(':andEngine')
    compile project(':andEnginePhysicsBox2DExtension')
    compile project(':downloader_library')
    compile project(':viewPagerLibrary')
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'org.apache.commons:commons-lang3:3.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:23.0.1'
}

On building gradle file I am getting below error of :

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

To solve this error I have already added multidex dependency :

 compile 'com.android.support:multidex:1.0.1'

Still looping around ..

Edited : Already solved problem so do not try to duplicate it and solution is below..!!

Hoping for help.!

Thanks.


Solution

  • You should add

      multiDexEnabled true
    

    in build.gradle

    defaultConfig {
    
        applicationId 'pkg'
        minSdkVersion 
        targetSdkVersion 
        versionCode 
        versionName 
    
        // Enable MultiDexing:  https://developer.android.com/tools/building/multidex.html
        multiDexEnabled true
    }