意外的顶级异常:com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]:65536中
我的Gradle文件中有以下依赖项:意外的顶级异常:com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]:65536中,android,android-studio,andengine,android-multidex,Android,Android Studio,Andengine,Android Multidex,我的Gradle文件中有以下依赖项: apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.0" defaultConfig { applicationId "packagename" minSdkVersion 10 targetSdkVersion 23 } so
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'
}
在构建gradle文件时,我得到以下错误:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
为了解决此错误,我已经添加了多索引依赖项:
compile 'com.android.support:multidex:1.0.1'
仍在循环
已编辑:问题已解决,请不要尝试复制,解决方案如下
希望得到帮助
谢谢。您应该添加
multiDexEnabled true
在build.gradle中
defaultConfig {
applicationId 'pkg'
minSdkVersion
targetSdkVersion
versionCode
versionName
// Enable MultiDexing: https://developer.android.com/tools/building/multidex.html
multiDexEnabled true
}
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
你应该加上
multiDexEnabled true
在build.gradle中
defaultConfig {
applicationId 'pkg'
minSdkVersion
targetSdkVersion
versionCode
versionName
// Enable MultiDexing: https://developer.android.com/tools/building/multidex.html
multiDexEnabled true
}
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
这意味着您的应用程序超过了android应用程序的65k方法计数限制。 看来你正在使用谷歌播放服务,这是巨大的
compile 'com.google.android.gms:play-services:8.1.0'
正如所说
您可以通过只使用上面相同链接中显示的播放服务来减少这种情况。
示例:如果您的应用程序只需要gcm,您可以使用其子集,如:
com.google.android.gms:play-services-gcm:8.1.0
等等。这意味着你的应用程序超过了android应用程序的65k方法计数限制。 看来你正在使用谷歌播放服务,这是巨大的
compile 'com.google.android.gms:play-services:8.1.0'
正如所说
您可以通过只使用上面相同链接中显示的播放服务来减少这种情况。
示例:如果您的应用程序只需要gcm,您可以使用其子集,如:
com.google.android.gms:play-services-gcm:8.1.0
等等。当您的整个项目有超过64000个方法时,就会出现此问题。 因此,您必须向应用程序
build.gradle
文件添加依赖项
compile 'com.android.support:multidex:1.0.0'
然后将此标记添加到应用程序项的AndrodManifest.xml
<application
...
android:name="android.support.multidex.MultiDexApplication">
然后下一步是在build.gradle
defaultConfig {
applicationId 'pkg'
minSdkVersion
targetSdkVersion
versionCode
versionName
// Enable MultiDexing: https://developer.android.com/tools/building/multidex.html
multiDexEnabled true
}
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
。。。
请参见当您的整个项目有超过64000个方法时,就会出现此问题。 因此,您必须向应用程序
build.gradle
文件添加依赖项
compile 'com.android.support:multidex:1.0.0'
然后将此标记添加到应用程序项的AndrodManifest.xml
<application
...
android:name="android.support.multidex.MultiDexApplication">
然后下一步是在build.gradle
defaultConfig {
applicationId 'pkg'
minSdkVersion
targetSdkVersion
versionCode
versionName
// Enable MultiDexing: https://developer.android.com/tools/building/multidex.html
multiDexEnabled true
}
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
。。。
请参见的可能重复如果您有多个模块,则必须将其添加到每个模块的android块中。如果您有多个模块,则必须将其添加到每个模块的android块中。