【问题标题】:java.util.zip.ZipException: duplicate entry: com/google/common/annotations/Beta.classjava.util.zip.ZipException:重复条目:com/google/common/annotations/Beta.class
【发布时间】:2018-07-03 11:51:55
【问题描述】:

运行我的项目时发生此错误,无法运行我的应用程序进行构建。

我已经清理了构建并再次重建项目导致同样的问题。

* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/common/annotations/Beta.class

我在下面分享了我的 gradle 文件。请帮助我找到要在 gradle 文件中进行的更改以运行我的应用程序。

Gradle 文件

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.crashlytics.sdk.android:crashlytics:2.5.0@aar') {
        transitive = true;
    }

    compile 'com.uber.sdk:rides-android:0.5.3'
    compile 'com.twitter.sdk.android:twitter:3.1.1'

    compile project(':branchsdk')
    compile project(':squarecamera')

    compile 'com.google.code.gson:gson:2.5'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
    compile 'com.facebook.rebound:rebound:0.3.8'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
    compile 'se.emilsjolander.stickylistheaders:library:2.1.0'
    compile ('com.android.support:support-v4:26.0.0')
            {   exclude group: 'org.apache.httpcomponents', module: 'httpclient'
                exclude module: 'support-annotations'
            }
    compile ('com.android.support:appcompat-v7:26.0.0'){
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
        exclude group: 'com.android.support'
    }

    compile 'com.github.siyamed:android-shape-imageview:0.9.2'
    compile 'com.adobe.creativesdk.foundation:auth:0.5.3'
    compile 'com.adobe.creativesdk.foundation:assets:0.5.3'
    compile 'com.adobe.creativesdk:image:4.0.0'
    compile 'com.github.bumptech.glide:glide:3.6.1'

    compile ('com.google.android.gms:play-services:11.6.2'){
        exclude group: 'com.google.guava'
    }

    compile 'com.parse:parse-android:1.10.2'
    compile 'org.altbeacon:android-beacon-library:2.5.1'
    compile 'org.apache.commons:commons-collections4:4.0'

    compile 'org.solovyev.android.views:linear-layout-manager:0.5@aar'
    compile 'de.greenrobot:eventbus:2.4.0'

    compile ('com.android.support:recyclerview-v7:26.0.0')
            {
                exclude group: 'com.android.support'
            }
    compile ('com.android.support:multidex:1.0.1')
            {
                exclude group: 'com.android.support'
            }

    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }

    compile 'me.relex:circleindicator:1.2.2@aar'
    compile 'com.google.firebase:firebase-config:11.6.2'
    compile 'com.google.firebase:firebase-messaging:11.6.2'

    compile project(':ucrop')
    compile project(':library')

    compile 'com.facebook.android:facebook-android-sdk:[4,5)'

    compile 'com.google.guava:guava:16.0.1'
}
apply plugin: 'com.google.gms.google-services'

请帮我解决这个问题。

在此先感谢...

【问题讨论】:

    标签: gradle android-gradle-plugin build.gradle


    【解决方案1】:

    我认为您对 Google 集合重命名为 guava 感到厌烦,您的类路径中可能两者都有。

    Using module replacement rules

    例如:

    dependencies {
        modules {
            module("com.google.collections:google-collections") {
                replacedBy("com.google.guava:guava", "google-collections is now part of Guava")
            }
        }
    }
    

    或者另一个问题可能是这样的

    fileTree(include: ['*.jar'], dir: 'libs')
    

    此 libs 文件夹中的 jar 无法参与依赖解析,因为没有元数据(例如组/工件/版本),因此这里也可能存在重复项

    请参阅here 以将本地 jar 存储在 maven 目录布局中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-07
      • 1970-01-01
      • 1970-01-01
      • 2017-11-22
      • 1970-01-01
      • 1970-01-01
      • 2018-07-09
      • 1970-01-01
      相关资源
      最近更新 更多