Java工具包中的异常:java.util.zip.ZipException:重复条目:android/support/v7/graphics/drawable/DrawableUtils.class

6

我刚刚将支持库从23.0.0升级到23.1.0,现在在构建项目时,出现了以下错误:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v7/graphics/drawable/DrawableUtils.class

这是我的应用级别build.gradle文件:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}


apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion "23"
    defaultConfig {
        applicationId 'com.galleri5.android'
        multiDexEnabled true
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 6
        versionName "0.6"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


repositories {
    mavenCentral()
    mavenLocal()
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:design:23.1.0'
    compile 'com.facebook.android:facebook-android-sdk:4.3.0'
    compile 'com.etsy.android.grid:library:1.0.5'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
    compile 'com.android.support:recyclerview-v7:23.1.0'
    compile 'com.android.support:cardview-v7:23.1.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.github.clans:fab:1.6.1'
    compile 'uk.co.chrisjenx:calligraphy:2.1.0'
    compile 'com.google.android.gms:play-services-analytics:8.1.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
        transitive = true;
    }
}

我为什么会收到这个错误?我想使用最新版本的支持库。我该如何解决这个问题?我阅读了这篇SO帖子,但是它提供的解决方案并没有起作用。它在我的代码库中产生了更多的错误。另外,我没有使用JAR文件。非常感谢您的帮助。谢谢。

1
清理项目应该有所帮助,并设置compileSdkVersion 23 buildToolsVersion "23.0.1" - IntelliJ Amiya
尝试过了,仍然得到相同的错误。 - Amit Tiwari
在终端中,在根项目文件夹下执行:./gradlew clean https://dev59.com/JVwX5IYBdhLWcg3w8TMf https://dev59.com/oFwY5IYBdhLWcg3wJU14 - Chaudhary Amar
1
是的,现在可以了。谢谢。清理项目可以解决。 - Amit Tiwari
我希望这个答案能够帮助到你... - Reza Nazeri
2个回答

8

我在我的React Native Android项目中遇到了同样的问题,以下方法解决了这个问题:

cd android

./gradlew clean

0

您需要在支持 V7 上添加排除组,就像这样:

compile ('com.android.support:appcompat-v7:19.+' ) {
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    exclude group: 'com.android.support'
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接