我面臨着同樣的問題。我的代碼適用於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