在我的项目中有一个问题,当我想在我的应用程序中添加谷歌播放依赖关系到谷歌地图.问题是当我想运行项目时我会给出这些错误:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:283)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution Failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_72\bin\java.exe'' finished with non-zero exit value 2
这是我的依赖:
android {
compileSdkVersion 22
buildToolsversion "22.0.1"
defaultConfig {
minSdkVersion 14
versionCode 2
versionName "1.0.1"
}
dependencies {
compile filetree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-v13:22.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile ('org.bouncycastle:bcprov-jdk16:1.46')
compile ('com.nineoldandroids:library:2.4.0')
compile ('commons-lang:commons-lang:2.6')
compile ('com.google.zxing:core:3.2.0')
}
我也删除了所有库,因为我虽然他们可能有谷歌播放8.1.0的问题,但没有改变.我还尝试从所有编译中排除com.google.android.gms:play-services,但它也没有用.
解决方法:
首先,要注意你的依赖块.
您使用的是同一个库的不同版本,可能是不必要的依赖项.
在任何情况下都使用相同的版本.
dependencies{
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-v13:22.0.0' ARE YOU SURE?
compile 'com.android.support:appcompat-v7:22.0.0' TWICE ? REMOVE IT
compile 'com.android.support:support-v4:22.0.0' APPCOMPAT contains it. REMOVE IT.
}
如果问题仍然存在,那么您的方法太多了. dex只能有65536种方法.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
由于gradle插件0.14.0和Build Tools 21.1.0可以使用multidex support.
只需在build.gradle中添加以下行:
android {
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
同样在您的Manifest中,将Multidex支持库中的MultiDexApplication类添加到application元素中
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
如果您使用自己的Application类,请将父类从Application更改为MultiDexApplication.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。