2016-06-16 3 views
2

Versuch zu laufen instrumentierten Test auszuführen, habe ich diesen Fehler:multidex App bekommt ZipException: doppelte Eintrag für junit, versuchen instrumentierten Test

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebugAndroidTest'. 
    com.android.build.api.transform.TransformException: 
    java.util.zip.ZipException: 
     duplicate entry: 
      org/junit/ClassRule.class 

Aber manchmal duplicate entry ist:

 duplicate entry: 
      junit/extensions/ActiveTestSuite$1.class 

Welche ist offensichtlich wahr: Control-N -> Eingabe ClassRule zeigt:

  1. C:\Users\me\.gradle\caches\modules-2\files-2.1\junit\junit\4.12\a6c32b40bf3d76eca54e3c601e5d1470c86fcdfa\junit-4.12-sources.jar!\org\junit\ClassRule.java
  2. C:\Users\me\.gradle\caches\modules-2\files-2.1\junit\junit-dep\4.10\64417b3bafdecd366afa514bd5beeae6c1f85ece\junit-dep-4.10.jar!\org\junit\ClassRule.class (dekompilierten .class-Datei, Bytecode-Version: 49,0 (Java 5,0)

Suche ActiveTestSuite 3 Ergebnisse gibt, die alle in C:\Users\me\.gradle\caches\modules-2\files-2.1\junit\

Gibt es einen Weg, um die Abhängigkeiten Diagramm zu sehen? Ich kommentierte alle junit aus der app/build.gradle verbunden sind ‚s Abschnitt Abhängigkeiten:

dependencies { 
    compile 'com.android.support:multidex:1.0.1' 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.google.firebase:firebase-core:9.0.2' 
    compile 'com.google.firebase:firebase-messaging:9.0.2' 
    /// <Dagger> 
    provided 'javax.annotation:jsr250-api:1.0' 
    apt 'com.google.dagger:dagger-compiler:2.0.1' 
    compile 'com.google.dagger:dagger:2.0.1' 
    compile 'com.google.dagger:dagger-compiler:2.0.1' 
    /// </Dagger> 

    // ------ JSON ... ------ 
    testCompile 'org.glassfish:javax.json:1.0.4' 
    testCompile 'com.fasterxml.jackson.core:jackson-databind:2.7.4' 
    // ------ ... JSON end ------ 
    apt 'com.jakewharton:butterknife-compiler:8.0.1' 

    //testCompile 'junit:junit:4.12' 
    testCompile 'org.mockito:mockito-core:1.10.19' 
    testCompile 'org.robolectric:robolectric:3.0' 
    //androidTestCompile 'junit:junit:4.12' 
    androidTestCompile 'org.mockito:mockito-core:1.10.19' 
    androidTestCompile 'org.robolectric:robolectric:3.0' 
    androidTestCompile 'com.android.support.test:testing-support-lib:0.1' 
    androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2'){ 
     exclude group: 'javax.inject' 
    } 

    compile 'com.android.support:appcompat-v7:23.3.0' 
    compile 'com.android.support:support-v13:23.3.0' 
    compile 'com.android.support:design:23.3.0' 
    compile 'com.jakewharton:butterknife:8.0.1' 
    compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.0' 
    compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3' 
    compile 'com.squareup.retrofit2:retrofit:2.0.2' 
    compile 'com.android.support:support-v4:23.3.0' 
    compile 'com.android.support:recyclerview-v7:23.3.0' 
    compile 'com.android.support:cardview-v7:23.3.0' 
    compile 'io.reactivex:rxandroid:1.2.0' 
    compile 'io.reactivex:rxjava:1.1.5' 
    //<Floating Buttons> 
    compile 'com.github.clans:fab:1.6.4' 
    //</Floating Buttons> 
    compile 'org.apache.commons:commons-lang3:3.4' 
} 
+0

dies versuchen, fügen .. Konfigurationen Gradle in { alle * .exclude Gruppe: 'com.android.support', Modul: 'Support-v4' } –

+0

@ WaqarYounis, ich habe das: 'configurations.all {resolutionStrategy.force 'com.android.support:support-annotations:23.3.0', 'junit: junit: 4.12'}' (Ich habe gerade das 'junit' hinzugefügt). Aber das Problem bleibt: 'java.util.zip.ZipException: doppelten Eintrag: junit/Extensions/ActiveTestSuite $ 1.class' – Tar

+0

versuchen Sie diese Kompilierung 'com.android.support:support-annotations:23.3.0 –

Antwort

0

Alles, was Sie tun müssen, ist unterhalb der Linie auf unsere Abhängigkeiten Liste hinzu:

testCompile "junit:junit:4.12' 

Dann zwingen diese Version von JUnit Abhängigkeit von das gesamte Projekt von unten Block in unserem app/build.gradle Zugabe:

configurations.all{ 
    resolutionStrategy.force 'junit:junit:4.12' 
} 

Dies wird alle Ihre Abhängigkeit Konflikt lösen s.

Für weitere Informationen: https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html

+0

Ich habe das: 'configurations.all {resolutionStrategy.force 'com.android.support:support-annotations:23.3.0', 'junit: junit: 4.12'}' (Ich habe das 'junit' dank Ihrer Antwort hinzugefügt) . Aber das Problem bleibt: 'java.util.zip.ZipException: doppelten Eintrag: junit/Extensions/ActiveTestSuite $ 1.class' – Tar

+0

Hallo @Tar, ich habe gerade erstellt Projekt alle Abhängigkeiten in Frage gestellt und Gradle Build funktioniert in meinem Fall. – Droidwala

+0

[build.gradle] (https: //gist.github.com/droidwala/bbbce2887418f1beadc1be8166d122f7) [app/build.gradle] (https://gist.github.com/droidwala/9188f4c4228b96b22ebc96d1f2c84c90) – Droidwala

Verwandte Themen