【问题标题】:TransformException duplicate entry for common.annotations.Betacommon.annotations.Beta 的 TransformException 重复条目
【发布时间】:2015-12-28 23:34:15
【问题描述】:

这开始于我添加google-api-services-calendar。尝试构建时出现此错误:

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

这是运行./gradlew app:dependencies时输出的一部分:

compile - Classpath for compiling the main sources.
+--- com.google.android.gms:play-services-measurement:8.1.0
|    +--- com.google.android.gms:play-services-base:8.1.0
|    |    \--- com.google.android.gms:play-services-basement:8.1.0
|    |         \--- com.android.support:support-v4:22.2.0 -> 23.0.1
|    |              \--- com.android.support:support-annotations:23.0.1
|    \--- com.google.android.gms:play-services-analytics:8.1.0
|         +--- com.google.android.gms:play-services-basement:8.1.0 (*)
|         \--- com.google.android.gms:play-services-ads:8.1.0
|              +--- com.google.android.gms:play-services-basement:8.1.0 (*)
|              \--- com.google.android.gms:play-services-appindexing:8.1.0
|                   \--- com.google.android.gms:play-services-basement:8.1.0 (*)
+--- com.google.dagger:dagger:2.0
|    \--- javax.inject:javax.inject:1
+--- com.google.android.gms:play-services-identity:8.1.0
|    \--- com.google.android.gms:play-services-base:8.1.0 (*)
+--- com.google.android.gms:play-services-plus:8.1.0
|    \--- com.google.android.gms:play-services-base:8.1.0 (*)
+--- com.google.android.gms:play-services:8.1.0
|    +--- com.google.android.gms:play-services-ads:8.1.0 (*)
|    +--- com.google.android.gms:play-services-analytics:8.1.0 (*)
|    +--- com.google.android.gms:play-services-appindexing:8.1.0 (*)
|    +--- com.google.android.gms:play-services-appinvite:8.1.0
|    |    \--- com.google.android.gms:play-services-base:8.1.0 (*)
|    +--- com.google.android.gms:play-services-appstate:8.1.0
|    |    \--- com.google.android.gms:play-services-base:8.1.0 (*)
|    +--- com.google.android.gms:play-services-base:8.1.0 (*)
|    +--- com.google.android.gms:play-services-basement:8.1.0 (*)
|    +--- com.google.android.gms:play-services-cast:8.1.0
|    |    +--- com.google.android.gms:play-services-base:8.1.0 (*)
|    |    \--- com.android.support:mediarouter-v7:22.2.0
|    |         \--- com.android.support:appcompat-v7:22.2.0 -> 23.0.1
|    |              \--- com.android.support:support-v4:23.0.1 (*)
|    +--- com.google.android.gms:play-services-drive:8.1.0
|    |    \--- com.google.android.gms:play-services-base:8.1.0 (*)
|    +--- com.google.android.gms:play-services-fitness:8.1.0
|    |    +--- com.google.android.gms:play-services-base:8.1.0 (*)
|    |    \--- com.google.android.gms:play-services-location:8.1.0
|    |         +--- com.google.android.gms:play-services-base:8.1.0 (*)
|    |         \--- com.google.android.gms:play-services-maps:8.1.0
|    |              \--- com.google.android.gms:play-services-base:8.1.0 (*)
|    +--- com.google.android.gms:play-services-games:8.1.0
|    |    +--- com.google.android.gms:play-services-base:8.1.0 (*)
|    |    \--- com.google.android.gms:play-services-drive:8.1.0 (*)
|    +--- com.google.android.gms:play-services-gcm:8.1.0
|    |    \--- com.google.android.gms:play-services-base:8.1.0 (*)
|    +--- com.google.android.gms:play-services-identity:8.1.0 (*)
|    +--- com.google.android.gms:play-services-location:8.1.0 (*)
|    +--- com.google.android.gms:play-services-maps:8.1.0 (*)
|    +--- com.google.android.gms:play-services-measurement:8.1.0 (*)
|    +--- com.google.android.gms:play-services-nearby:8.1.0
|    |    \--- com.google.android.gms:play-services-base:8.1.0 (*)
|    +--- com.google.android.gms:play-services-panorama:8.1.0
|    |    \--- com.google.android.gms:play-services-base:8.1.0 (*)
|    +--- com.google.android.gms:play-services-plus:8.1.0 (*)
|    +--- com.google.android.gms:play-services-safetynet:8.1.0
|    |    \--- com.google.android.gms:play-services-base:8.1.0 (*)
|    +--- com.google.android.gms:play-services-vision:8.1.0
|    |    \--- com.google.android.gms:play-services-base:8.1.0 (*)
|    +--- com.google.android.gms:play-services-wallet:8.1.0
|    |    +--- com.google.android.gms:play-services-base:8.1.0 (*)
|    |    +--- com.google.android.gms:play-services-identity:8.1.0 (*)
|    |    \--- com.google.android.gms:play-services-maps:8.1.0 (*)
|    \--- com.google.android.gms:play-services-wearable:8.1.0
|         \--- com.google.android.gms:play-services-base:8.1.0 (*)
+--- com.google.guava:guava:18.0
+--- com.google.maps.android:android-maps-utils:0.4
+--- com.google.apis:google-api-services-calendar:v3-rev125-1.20.0
|    \--- com.google.api-client:google-api-client:1.20.0
|         +--- com.google.oauth-client:google-oauth-client:1.20.0
|         |    +--- com.google.http-client:google-http-client:1.20.0
|         |    |    \--- com.google.code.findbugs:jsr305:1.3.9
|         |    \--- com.google.code.findbugs:jsr305:1.3.9
|         +--- com.google.http-client:google-http-client-jackson2:1.20.0
|         |    +--- com.google.http-client:google-http-client:1.20.0 (*)
|         |    \--- com.fasterxml.jackson.core:jackson-core:2.1.3 -> 2.2.2
|         \--- com.google.guava:guava-jdk5:13.0
+--- com.android.support:design:23.0.1
|    +--- com.android.support:support-v4:23.0.1 (*)
|    \--- com.android.support:appcompat-v7:23.0.1 (*)
+--- com.android.support:recyclerview-v7:23.0.1
|    +--- com.android.support:support-v4:23.0.1 (*)
|    \--- com.android.support:support-annotations:23.0.1
+--- com.android.support:cardview-v7:23.0.1
+--- com.android.support:palette-v7:23.0.1
|    \--- com.android.support:support-v4:23.0.1 (*)
+--- com.android.support:appcompat-v7:22.2.0 -> 23.0.1 (*)
+--- com.android.support:support-v4:22.2.0 -> 23.0.1 (*)
+--- com.firebase:firebase-client-android:2.3.1
|    \--- com.firebase:firebase-client-jvm:2.3.1
|         +--- com.fasterxml.jackson.core:jackson-databind:2.2.2
|         |    +--- com.fasterxml.jackson.core:jackson-annotations:2.2.2
|         |    \--- com.fasterxml.jackson.core:jackson-core:2.2.2
|         \--- com.firebase:tubesock:0.0.11
+--- com.firebase:firebase-client-jvm:2.3.0 -> 2.3.1 (*)
+--- net.danlew:android.joda:2.8.0
|    \--- joda-time:joda-time:2.8
+--- org.joda:joda-convert:1.2
+--- com.squareup:otto:1.3.5
+--- com.jakewharton:butterknife:7.0.1
+--- org.apache.commons:commons-lang3:3.4
+--- org.apache.commons:commons-collections4:4.0
\--- com.bignerdranch.android:expandablerecyclerview:1.0.3
     \--- com.android.support:recyclerview-v7:22.2.0 -> 23.0.1 (*)

我已尝试将其添加到 所有我的依赖项:

compile (some.dependencie.that.may.or.may.not.have.the.duplicate){
    exclude group: 'com.google.common', module: 'annotations'
}

我尝试将此添加到我的 android 块中:

configurations {
   all*.exclude group: 'com.google.common', module: 'annotations'
}    

有这些变化:

 all*.exclude module: 'annotations`
 all*.exclude group: 'com.google.common'
 all*.exclude group: 'com.google.common.annotations'

这是build.gradle任何尝试修复错误之前:

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

    // Google
    compile 'com.google.dagger:dagger:2.0'
    apt 'com.google.dagger:dagger-compiler:2.0'
    compile 'com.google.android.gms:play-services-identity:8.1.0'
    compile 'com.google.android.gms:play-services-plus:8.1.0'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.google.guava:guava:18.0'
    compile 'com.google.maps.android:android-maps-utils:0.4'
    compile('com.google.apis:google-api-services-calendar:v3-rev125-1.20.0') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }

    // Android Design
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:palette-v7:23.0.1'

    // Android Support
    compile('com.android.support:appcompat-v7:22.2.0') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    compile('com.android.support:support-v4:22.2.0') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }

    // Firebase
    compile('com.firebase:firebase-client-android:2.3.1') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    compile('com.firebase:firebase-client-jvm:2.3.0') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }

    // Joda Time
    compile 'net.danlew:android.joda:2.8.0'
    compile 'org.joda:joda-convert:1.2'

    // Square
    compile 'com.squareup:otto:1.3.5'
    compile 'com.jakewharton:butterknife:7.0.1'
    provided 'javax.annotation:jsr250-api:1.0'

    // Common
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'org.apache.commons:commons-collections4:4.0'

    compile 'com.bignerdranch.android:expandablerecyclerview:1.0.3'
}

我在我的项目中搜索了Beta.class,发现它只在一些jar中使用; com.google.common.annotationscom.google.api.client.utildagger.internal。我尝试将exclude group 添加到那些相关的依赖项中,但仍然看到相同的错误。

我被困在这里太久了。有什么建议?

【问题讨论】:

  • 我刚刚在将 Android Gradle 插件更新为 com.android.tools.build:gradle:1.4.0-beta3 时遇到了这个问题。就我而言,问题出在 AndroidSlidingUpPanelLayout 上,它又依赖于 Nineoldandroids (link),它会产生错误。我“修复”了它回到 com.android.tools.build:gradle:1.3.0。
  • 我还在 1.3.0 上,自从它出来后就没变过。
  • @ChadBingham 你可以尝试排除com.google.guava:guava-jdk5:13.0 模块吗?然后,再次运行任务?
  • @kucing_terbang 对此进行扩展,从什么模块中排除番石榴?还是从番石榴中排除什么?
  • @ChadBingham 来自google-api-services-calendar 模块。

标签: java android dependencies duplicates android-gradle-plugin


【解决方案1】:

当我的应用模块和库模块中有不同版本的播放服务库时,我收到了这个错误。

【讨论】:

  • 太棒了!只有这个答案解决了我的问题,感谢提及!
【解决方案2】:

我发现原因是dagger-compiler配置错误:

compile 'com.google.dagger:dagger-compiler:2.1'

我所做的是修改项目的 build.gradle:

buildscript {
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

以及后来的应用 build.gradle:

首先,添加插件:

apply plugin: 'com.neenbedankt.android-apt'

然后将依赖修改为:

apt "com.google.dagger:dagger-compiler:2.1"

【讨论】:

  • 我有同样的问题,有一个条目:apt 'com.google.dagger:dagger-compiler:2.1' 然后另一个:compile 'com.google.dagger:dagger-compiler:2.1'摆脱 compile 条目为我解决了 TransformException。
【解决方案3】:

从播放服务相关的依赖项中排除group: 'com.google.guava'

例如:

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

附:在收到您的错误之前,我遇到了很多不同的问题,所以我的最终依赖项列表是:

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

    // Google
    compile 'com.google.dagger:dagger:2.0'
    apt 'com.google.dagger:dagger-compiler:2.0'
    compile ('com.google.android.gms:play-services-identity:8.1.0'){
        exclude group: 'com.google.guava'
    }
    compile ('com.google.android.gms:play-services-plus:8.1.0'){
        exclude group: 'com.google.guava'
    }
    compile ('com.google.android.gms:play-services:8.1.0'){
        exclude group: 'com.google.guava'
    }
    compile 'com.google.guava:guava:18.0'
    compile 'com.google.maps.android:android-maps-utils:0.4'

    compile('com.google.apis:google-api-services-calendar:v3-rev125-1.20.0') {
        exclude group: 'org.apache.httpcomponents'
        exclude group: 'com.android.support'
        exclude module: 'support-annotations'
        exclude group: 'com.google.guava'
    }

    // Android Design
    compile ('com.android.support:design:23.0.1'){
        exclude group: 'com.android.support'
    }
    compile ('com.android.support:recyclerview-v7:23.0.1') {
        exclude group: 'com.android.support'
    }

    compile 'com.android.support:cardview-v7:23.0.1'
    compile ('com.android.support:palette-v7:23.0.1'){
        exclude group: 'com.android.support'
    }

    // Android Support
    compile('com.android.support:appcompat-v7:22.2.0') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
        exclude group: 'com.android.support'
    }

    compile 'com.android.support:support-annotations:23.0.1'
    compile('com.android.support:support-v4:22.2.0') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
        exclude module: 'support-annotations'
    }

    // Firebase
    compile('com.firebase:firebase-client-android:2.3.1') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    compile('com.firebase:firebase-client-jvm:2.3.0') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }

    // Joda Time
    compile 'net.danlew:android.joda:2.8.0'
    compile 'org.joda:joda-convert:1.2'

    // Square
    compile 'com.squareup:otto:1.3.5'
    compile 'com.jakewharton:butterknife:7.0.1'
    provided 'javax.annotation:jsr250-api:1.0'

    // Common
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'org.apache.commons:commons-collections4:4.0'

    compile ('com.bignerdranch.android:expandablerecyclerview:1.0.3'){
        exclude group: 'com.android.support'
    }
}

【讨论】:

  • 为什么guava是需要排除的?
  • @IgorGanapolsky,我试图直观地排除番石榴。番石榴确实是个问题。我不知道为什么......
  • 我也有同样的问题。我在 libs 文件夹以及 gradle 依赖项中使用了相同的库。我在一个地方删除了,问题就消失了。
  • 我发现删除对番石榴的引用更简单 //compile 'com.google.guava:guava:20.0'
  • 我收到“重复条目:com/google/api/client/util/ArrayMap$Entry.class”
猜你喜欢
  • 2017-03-14
  • 1970-01-01
  • 1970-01-01
  • 2016-06-28
  • 1970-01-01
  • 1970-01-01
  • 2017-08-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多