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

时间:2018-07-03 11:51:55

标签: gradle android-gradle 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文件中找到要执行的更改以运行我的应用程序。

成绩文件

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'

请帮助我解决此问题。

预先感谢...

1 个答案:

答案 0 :(得分:0)

我认为您会被Google集合重命名为番石榴而感到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目录布局中