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

前端之家收集整理的这篇文章主要介绍了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兼容包详解

猜你在找的设计模式相关文章