简体   繁体   中英

Android Espresso Test Failed With Dex For Debug Android Test

I am trying to run a simple Espresso Test and it is failing with the error message

Error:Execution failed for task ':app:transformClassesWithDexForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2

I have commented out a lot of my gradle dependencies. And here is the Test that is causing the failure. The main App can run but not the test

@RunWith(AndroidJUnit4.class)
@LargeTest
public class ScheduleActivityTest {
    @Rule
    public final ActivityTestRule<ScheduleActivity> schedule = new ActivityTestRule<>(ScheduleActivity.class);

    @Test
    public void shouldBeVisible() throws Exception {
        onView(withId(R.layout.activity_schedule))
                .check((ViewAssertion) isDisplayed());

    }
}

And here is my gradle file

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

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.okason.prontosalon"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }

   dependencies {

    compile 'com.android.support:support-annotations:23.1.1'

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('com.mikepenz:materialdrawer:4.6.4@aar') {
        transitive = true
    }
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'

    compile 'com.squareup:otto:1.3.8'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'com.mikepenz:fontawesome-typeface:4.4.0.1@aar'

    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
    androidTestCompile 'com.android.support.test:runner:0.4.1'
    androidTestCompile 'com.android.support.test:rules:0.4.1'
    androidTestCompile 'com.android.support:support-annotations:23.1.1'
    androidTestCompile 'com.android.support.test:testing-support-lib:0.1'


}

What could I be doing wrong?. Here is my Project Structure

在此处输入图片说明

Could you try adding dexOptions to your app/build.gradle.

dexOptions {
  jumboMode = true
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM