web-dev-qa-db-fra.com

Entrée en double TransformException pour common.annotations.Beta

Cela a commencé lorsque j'ai ajouté google-api-services-calendar. J'obtiens cette erreur en essayant de construire:

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

Cela fait partie de la sortie lors de l'exécution de ./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 (*)

J'ai essayé d'ajouter ceci à toutes mes dépendances:

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

J'ai essayé d'ajouter ceci à mon bloc Android:

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

avec ces variations:

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

C'est le build.gradle avant toute tentative de correction d'erreur:

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

J'ai recherché mon projet pour Beta.class et a constaté qu'il n'est utilisé que dans certains bocaux; com.google.common.annotations, com.google.api.client.util et dagger.internal. J'ai essayé d'ajouter le exclude group à ces dépendances liées et voit toujours la même erreur.

Je suis coincé ici depuis trop longtemps. Aucune suggestion?

30
Chad Bingham

Exclure group: 'com.google.guava' à partir des dépendances liées aux services de jeu.

Par exemple:

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

P.S. Avant d'obtenir votre erreur, j'ai rencontré beaucoup de choses différentes, donc ma liste finale de dépendances est:

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'
    }
}
23
Oleksandr

J'ai eu cette erreur lorsque j'avais différentes versions des bibliothèques de services de jeu dans mon module d'application et un module de bibliothèque.

2
Vasudev

J'ai trouvé la raison d'être incorrectement configuré dagger-compiler:

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

Ce que j'avais fait, c'était de modifier le projet 'build.gradle:

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

Et plus tard, l'application build.gradle:

Tout d'abord, ajoutez un plugin:

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

Et modifiez plus tard la dépendance pour:

apt "com.google.dagger:dagger-compiler:2.1"
1
Paweł Szczur