运行androidTest检测Espresso测试时获取错误java.lang.NoClassDefFoundError

时间:2017-07-03 11:44:13

标签: java android android-espresso

当我在Android Studio中运行Espresso测试时出现此错误。我尝试导入DaggerRuntime但仍然没有帮助。

java.lang.NoClassDefFoundError: android.support.test.espresso.base.BaseLayerModule_ProvideFailureHanderFactory
    at android.support.test.espresso.DaggerBaseLayerComponent.initialize(DaggerBaseLayerComponent.java:66)
    at android.support.test.espresso.DaggerBaseLayerComponent.<init>(DaggerBaseLayerComponent.java:54)
    at android.support.test.espresso.DaggerBaseLayerComponent.<init>(DaggerBaseLayerComponent.java:40)
    at android.support.test.espresso.DaggerBaseLayerComponent$Builder.build(DaggerBaseLayerComponent.java:123)
    at android.support.test.espresso.DaggerBaseLayerComponent.create(DaggerBaseLayerComponent.java:62)
    at android.support.test.espresso.GraphHolder.baseLayer(GraphHolder.java:42)
    at android.support.test.espresso.Espresso.<clinit>(Espresso.java:51)

1 个答案:

答案 0 :(得分:0)

尝试删除build.gradle文件中的支持库

androidTestCompile 'com.jakewharton.espresso:espresso:1.1-r3'
androidTestCompile ('com.jakewharton.espresso:espresso-support-v4:1.1-r3') {
    exclude group:'com.android.support', module:'support-v4'
}