Unable to merge dex,专治Android Studio各种抽风!

今天在洗一个项目时,报错:

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是不是有重复的包

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值