您的位置:首页 > 移动开发 > Android开发

Android 打包签名DexIndexOverflowException错误解决

2016-10-12 10:53 423 查看
应用要使用谷歌地图服务,集成了Google Play Services,使用Android Studio打包release版本编译的时候出现如下错误:

Error:Execution failed for task ':watchclient:transformClassesWithDexForRelease'.

> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536


DexIndexOverflowException,从名字上看是Dex的Index溢出了。在stackoverflow上看到64K的说法:

当出现这个错误时说明你本身自己的工程代码中含有的太多的方法,或者你的工程lib文件夹下引用的第三方插件jar包有太多的方法,这两者的方法加起来已经超过了65536这个数目。而谷歌规定单个dex文件中的方法不能超过65536的限制

解决方案如下,修改module的build.gradle:

dependencies {
...
compile 'com.android.support:multidex:'
...
}


android {
...
defaultConfig {
...
multiDexEnabled true
...
}
...
}


这样就解决了DexIndexOverflowException这个异常:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐