今天在洗一个项目时,报错:
Error:Execution failed for task ':app:transform Dex Archive With External Libs Dex Merger For Debug'.
> java.lang.Runtime Exception: java.lang.Runtime Exception: com.android.builder.dexing.Dex Archive Merger Exception: Unable to merge dex
翻译器:
错误:执行失败的任务':应用程序:转换Dex存档与外部库Dex合并调试'。
> java.lang.Runtime异常:java.lang.Runtime异常:com.android.builder.dexing.Dex归档合并异常:无法合并dex
因为刚刚依赖了一个开源库就出了这样的错误,我想,一定是这里的原因,于是,开始上网查找
遇到的错误:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.3.0, 23.4.0. Examples includecom.android.support:animated-vector-drawable:25.3.0 and com.android.support:design:23.4.0more... (Ctrl+F1)
他的解决办法是:
处理:加入相同版本的依赖,重新编译
compile 'com.android.support:support-v4:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.android.support:appcompat-v7:25.3.0'
我试过了,还是报错
于是,我灵机一现:一定是引入了重复的lib导致的:
开始翻这个库的源码:
dependencies {
compile 'com.android.support:appcompat-v7:25+'
compile 'com.android.support:design:25.1.0'
compile project(':liboverscroll')
mmp:还是依赖的一个moudle
}
dependencies {
compile 'com.android.support:recyclerview-v7:25.1.0'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
testCompile "org.robolectric:robolectric:3.0"
}
哈哈,原来他也引入了一个recyclerview
然后删掉我的recyclerview,重新编译,成功了!
当你遇到这样的错误时,一定要先检查你的build.gradle是不是有重复的包