任务':app:preDexDebugAndroidTest'

时间:2016-01-20 16:47:42

标签: android cucumber android-espresso

我正在尝试使用Espresso和Cucumber在Android Studio中设置框架。

当我尝试运行Android测试配置时,构建失败会给我以下异常:

任务执行失败':app:preDexDebugAndroidTest'。

  

com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'命令'/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java ''以非零退出值1结束

这是我的bundle.gradle文件依赖项。

apply plugin:'com.android.application'

android {     compileSdkVersion 23     buildToolsVersion“23.0.2”

defaultConfig {
    applicationId "testapp.drayson.com.testapp"
    minSdkVersion 18
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
   // multiDexEnabled true
    testInstrumentationRunner "testapp.drayson.com.testapp.Instrumentation"
}

sourceSets {
    androidTest {
        assets.srcDirs = ['src/androidTest/assets']
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
lintOptions {
    abortOnError false
}

}

依赖{     编译fileTree(dir:'libs',包括:['* .jar'])

androidTestCompile 'com.android.support:support-annotations:23.1.0'
androidTestCompile('com.android.support.test:runner:0.3')
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'

//Cucumber
androidTestCompile 'info.cukes:cucumber-android:1.2.0@jar'
androidTestCompile 'info.cukes:cucumber-picocontainer:1.2.4'
androidTestCompile('info.cukes:cucumber-junit:1.1.4') {
    exclude module: 'cucumber-jvm-deps'
    exclude module: 'cucumber-core'
    exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
androidTestCompile('info.cukes:cucumber-jvm:1.2.4') {
}
androidTestCompile('info.cukes:cucumber-core:1.2.4') {
    exclude module: 'cucumber-jvm-deps'
}
androidTestCompile('info.cukes:cucumber-jvm-deps:1.0.3') {
}

//Espresso
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1') {
    exclude module: 'junit'
    exclude module: 'runner'
}
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
    exclude module: 'espresso-core'
    exclude module: 'support-v4'
}

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'

}

1 个答案:

答案 0 :(得分:1)

尝试在

中添加 multiDexEnabled 作为 true
buildType{ release{ multiDexEnabled true} }

希望它对你有用..