意外的最高级别异常:com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]中:65536

And*_*eky 1 android andengine android-studio android-multidex

我的Gradle文件中有以下依赖项:

 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'
}
Run Code Online (Sandbox Code Playgroud)

在构建gradle文件时,我得到以下错误:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Run Code Online (Sandbox Code Playgroud)

为了解决此错误,我已经添加了multidex依赖项:

 compile 'com.android.support:multidex:1.0.1'
Run Code Online (Sandbox Code Playgroud)

还在循环..

编辑:已解决问题,所以不要尝试复制它,解决方案如下.. !!

希望获得帮助。

谢谢。

M D*_*M D 5

您应该添加

  multiDexEnabled true
Run Code Online (Sandbox Code Playgroud)

build.gradle

defaultConfig {

    applicationId 'pkg'
    minSdkVersion 
    targetSdkVersion 
    versionCode 
    versionName 

    // Enable MultiDexing:  https://developer.android.com/tools/building/multidex.html
    multiDexEnabled true
}
Run Code Online (Sandbox Code Playgroud)