Error when configuring test environment

Asked

Viewed 74 times

1

When running a test, simple to check the settings, the following error appears:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebugAndroidTest'. com.android.build.api.Transform.Transformexception: java.util.zip.Zipexception: Duplicate entry: org/hamcrest/Basedescription.class

Test class:

@RunWith(AndroidJUnit4.class)
public class ActivityTest {
    public static SearchRidesFragment searchRidesFragment;

    @Rule
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
            MainActivity.class);

    @Test
    @SmallTest
    public void show(){
        onView(withId(R.id.search)).check(matches(isDisplayed()));

    }

}

Gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'https://clojars.org/repo' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://clojars.org/repo' }
}


android {
    signingConfigs {
        config {
            keyAlias 'bAndroid'
            keyPassword 'ab23'
            storePassword 'ab123'
            storeFile file('../cer/android.jks')
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    lintOptions {
        // but continue the build even when errors are found:
        abortOnError false
    }
    defaultConfig {
        applicationId "com.holandago.ur.b"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 66
        versionName "2.9.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        debug {
            debuggable true
            testCoverageEnabled = true
        }
        release {
            debuggable false
            signingConfig signingConfigs.config
            ext.betaDistributionEmails = "[email protected]"
            ext.betaDistributionReleaseNotes = "Release Notes for this build."
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'LICENSE.txt'
    }
    productFlavors {
    }
}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    compile('com.crashlytics.sdk.android:crashlytics:2.5.6@aar') {
        transitive = true;
    }
    testCompile 'junit:junit:4.12'
    testCompile 'org.robolectric:robolectric:3.0'
    testCompile 'org.mockito:mockito-all:1.10.19'
    testCompile 'org.hamcrest:hamcrest-library:1.3'
    androidTestCompile 'org.hamcrest:hamcrest-core:1.3'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    androidTestCompile 'com.google.code.gson:gson:2.6.1'
    androidTestCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support:support-annotations:23.4.0'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test:rules:0.5'
    androidTestCompile 'org.mockito:mockito-all:1.10.19'
    apt 'com.jakewharton:butterknife-compiler:8.0.1'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.koushikdutta.ion:ion:1.3.8'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.pusher:pusher-java-client:0.3.3'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'com.mixpanel.android:mixpanel-android:4.6.4'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.jakewharton:butterknife:8.0.1'
    compile 'com.android.support:support-annotations:23.4.0'
    compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.1.0-beta.1@aar') {
        transitive = true
    }
    compile('com.mapbox.mapboxsdk:mapbox-android-services:1.1.0@aar') {
        transitive = true
    }
}

Any suggestions?

  • Try to adapt that answer for your question. Abs

  • @seamusd opa. It’s another mistake. Even using me this old help of yours, it returns me this error. I returned a commit I had done with this Radle and mesmom so it gave problem.

1 answer

0


It was only possible to resolve by returning a different commit and branch than these changes.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.