在检测测试中未找到AndroidJUnit4.class

在检测测试中未找到AndroidJUnit4.class,android,junit,android-testing,android-junit,Android,Junit,Android Testing,Android Junit,我在导入AndroidJunit4.class时遇到问题。 我在androidTest/java/文件夹中创建了测试类,但似乎找不到该类 即使我强制正确导入,它仍然不起作用。(导入android.support.test) 这是我的毕业证书: defaultConfig { testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } dependencies { compile

我在导入AndroidJunit4.class时遇到问题。 我在
androidTest/java/
文件夹中创建了测试类,但似乎找不到该类

即使我强制正确导入,它仍然不起作用。(
导入android.support.test

这是我的毕业证书:

defaultConfig {
 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

dependencies {
 compile "com.android.support:support-annotations:23.4.0"
 compile "com.android.support:appcompat-v7:23.4.0"
 compile 'cat.ereza:customactivityoncrash:1.5.0'
 testCompile 'junit:junit:4.12'
 androidTestCompile 'junit:junit:4.12'
 androidTestCompile('com.android.support.test:runner:0.5')
 androidTestCompile('com.android.support.test:rules:0.5')
 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2')
 androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2')
 androidTestCompile('com.android.support.test.espresso:espresso-intents:2.2.2')

 testCompile('com.android.support.test:runner:0.5')
 testCompile('com.android.support.test:rules:0.5')
 testCompile('com.android.support.test.espresso:espresso-core:2.2.2')
 testCompile('com.android.support.test.espresso:espresso-contrib:2.2.2')
 testCompile('com.android.support.test.espresso:espresso-intents:2.2.2')

 testCompile 'org.mockito:mockito-core:1.10.19'
 testCompile "org.robolectric:robolectric:3.1.1"
}

奇怪的是,我可以在我的项目中找到
AndroidJunit4
文件,但在它的父级
AndroidJunit4ClassRunner
中,
AndroidRunnerParams
类没有解析,即使我也可以在我的项目中找到该文件。

注释掉注释

//@RunWith(AndroidJunit4.class)
在Android Studio中,选择“构建>重建项目”

重新获取注释

@RunWith(AndroidJunit4.class)

ALT-ENTER->Import class

您是否也在defaultConfig下添加了
TestInstrumentRunner“android.support.test.runner.AndroidJUnitRunner”
?是的,我也添加了它,我忘了注意上面的内容。
@RunWith(AndroidJunit4.class)