gradle - java.util.zip.ZipException:重复项:com/google/common/annotations/Beta.class

标签 gradle android-gradle-plugin build.gradle

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

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

* 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'

请帮助我解决这个问题。

提前致谢...

最佳答案

我想您会被Google集合重命名为 Guava 而感到st恼,并且您的类路径中可能都包含了两者。

参见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无法参与依赖关系解析,因为没有元数据(例如group / artifact / version),因此这里也可能存在重复项

参见here将本地jar保存在Maven目录布局中

关于gradle - java.util.zip.ZipException:重复项:com/google/common/annotations/Beta.class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51153934/

相关文章:

gradle - 是否可以跳过特定类型的所有 gradle 任务?

Android构建警告将新ns映射到旧ns

android - "WARNING: API ' 变体.getMergeResources() ' is obsolete and has been replaced with ' 变体.getMergeResourcesProvider() '."

android - Gradle 。无法构建简单的Android项目

android - 如何修复 android build.gradle 中的混合版本? (库必须使用完全相同的版本)

android - 错误:无法解决:vectordrawable-animated

java - Libgdx firebase robovm 绑定(bind)

android - Android Studio升级Gradle错误

java - Android Gradle 同步失败 : Could not resolve all artifacts for configuration ':classpath'

android - 最新 Android Studio 更新 3.3.2 后 Unresolved DataBinding 依赖关系