Gradle打包冲突,exclude依赖

最近引用Fresco,遇到了一堆引用报错导致编译不同过。下面是中文引导:

《Gradle打包冲突,exclude依赖》

然后集成这些第3方库会引起:

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ‘:moffice:transformClassesWithJarMergingForDebug’.> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/DrawableRes.class

* Try:

         Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.

         BUILD FAILED

其中annotation这个包多处引用:

解法:

《Gradle打包冲突,exclude依赖》

利用终端:

gradlew :{appname}:dependencies  会罗列出你所有的改project依赖

《Gradle打包冲突,exclude依赖》

这些都是引用树,你需要找到冲突的包然后干掉他

_debugCompile –  ##Internal use, do not manually configure## 

\— com.android.support:appcompat-v7:23.4.0

+— com.android.support:animated-vector-drawable:23.4.0

|    \— com.android.support:support-vector-drawable:23.4.0

|        \— com.android.support:support-v4:23.4.0

|              \— com.android.support:support-annotations:23.4.0

+— com.android.support:support-v4:23.4.0 (*)

\— com.android.support:support-vector-drawable:23.4.0 (*)

怎么改掉呢?

看这个:Gradle脚本分析http://www.open-open.com/lib/view/open1431391503529.html }

大致这样:

compile (‘com.android.support:recyclerview-v7:23.4.0’) {

                exclude group:’com.android.support’

}

希望能帮助到你

    原文作者:TragedyGo
    原文地址: https://www.jianshu.com/p/e80752d0d63b
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞