support-v4、support-v7 的依赖关系及 Getting java.util.zip.ZipException: duplicate entry exception 的处理

最近在编译项目时,多次出现了 java.util.zip.ZipException: duplicate entry exception android/support/vX/.../xxx.class 异常;
该异常是由于多个 module 或 第三方库(这个是主要原因)引用了不同版本的 support 库引起的;为了解决这个问题顺带把 Android support 库和
几个第三方库的依赖关系整理如下:

1.support-v7 的依赖关系

compile ("com.android.support:appcompat-v7:$SUPPORT_APPCOMPAT_V7_VERSION"){
        exclude group:'com.android.support',module:'support-v4'
        exclude group:'com.android.support',module:'support-annotations'
        exclude group:'com.android.support',module:'support-compat'
        exclude group: 'com.android.support',module: 'support-vector-drawable'
        exclude group:'com.android.support',module:'animated-vector-drawable'
    }

compile ("com.android.support:recyclerview-v7:$SUPPORT_RECYCLERVIEW_V7"){
        exclude group:'com.android.support',module:'support-compat'
        exclude group:'com.android.support',module:'support-core-ui'
    }

2.support-v13 的依赖关系

compile ("com.android.support:support-v13:$SUPPORT_V13"){
        exclude group:'com.android.support',module:'support-core-ui'
        exclude group:'com.android.support',module:'support-core-utils'
        exclude group:'com.android.support',module:'support-fragment'
        exclude group:'com.android.support',module:'support-media-compat'

        exclude group: 'com.android.support',module: 'recyclerview-v7'
    }

3.transition 的依赖关系

compile ("com.android.support:transition:$TRANSITION_VERSION"){
        exclude group:'com.android.support',module:'support-media-compat'

        exclude group:'com.android.support',module:'animated-vector-drawable'
    }

4.design 的依赖关系

compile("com.android.support:design:$DESIGN_VERSION") {
        exclude group:'com.android.support',module:'animated-vector-drawable'
        exclude group: 'com.android.support',module: 'support-vector-drawable'
        exclude group: 'com.android.support',module: 'transition'

        exclude group:'com.android.support',module:'appcompat-v7'
        exclude group: 'com.android.support',module: 'recyclerview-v7'

    }

5.constraint 的依赖关系

compile ('com.android.support.constraint:constraint-layout:1.0.2'){
        exclude group:'com.android.support',module:'support-v4'
    }

6.multidex 的依赖关系

compile ("com.android.support:multidex:$SUPPORT_MULTIDEX"){
        exclude group:'com.android.support',module:'support-v4'
    }

7.com.yuyh.imgsel(github上一图片选择器) 的依赖关系

compile ('com.yuyh.imgsel:library:1.3.8'){
        exclude group:'com.android.support',module: 'recyclerview-v7'
    }

8.ch.acra 的依赖关系

compile ('ch.acra:acra:4.9.1'){
        exclude group:'com.android.support',module:'support-v4'
    }

参考资料

关于 support-v4、support-v7 内部的构成可以看下面两篇 blog :

Android Support Library详细介绍
Android Support兼容包详解

相关文章

迭代器模式(Iterator)迭代器模式(Iterator)[Cursor]意图...
高性能IO模型浅析服务器端编程经常需要构造高性能的IO模型,...
策略模式(Strategy)策略模式(Strategy)[Policy]意图:定...
访问者模式(Visitor)访问者模式(Visitor)意图:表示一个...
命令模式(Command)命令模式(Command)[Action/Transactio...
生成器模式(Builder)生成器模式(Builder)意图:将一个对...