Gradle-踩坑

在安卓开发中肯定会使用到第三方库,gradle提供了一种快捷的依赖方式,但在开发中遇到了下面这种情况我们要怎么解决呢?

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

错误

这个错误是指你的项目中存在两个相同的依赖库,在我项目中遇到的是:

compile'com.allenliu.versionchecklib:library:2.0.3'   和

implementation'com.android.support:appcompat-v7:26.1.0'   产生了冲突。

即versionchecklib:library这个库已经依赖了com.android.support,就等于你项目中存在两个com.android.support库。

解决办法:使用gradle的exclue排除某些库。

栗子:api ("com.allenliu.versionchecklib:library:2.0.3") {

                exclude group:'com.android.support'

            }

问题解决。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。