我面临着同样的问题。我的代码适用于Android 7.1.1模拟器,但在Android 8.0模拟器上失败。 我通过在build.gradle中执行以下操作来解决问题。
1)升级咖啡文库。 我是:
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:runner:1.0.0'
androidTestCompile 'com.android.support.test:rules:1.0.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.0'
androidTestCompile('com.android.support.test.espresso:espresso-contrib:3.0.0')
2)这样做之后,你的应用程序可能无法建立。它可能会说这是不可能找到测试:亚军:1.0.0 在这种情况下,你需要添加
repositories {
maven { url "https://maven.google.com" }
}
3)您可能需要解决以下的问题是,它可能会抱怨“版本的应用程序(2x.xx)和测试应用程序(2x.xx)不同“ 因此,我在gradle中添加以下内容。
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:2x.x.x'
}
4)另外,您可能需要确保您已添加Runner。
defaultConfig {
"android.support.test.runner.AndroidJUnitRunner"
}
来源
2017-08-18 16:51:54
Wae
你找到答案吗?我一直面临同样的问题! :( – dira