gpt4 book ai didi

android - 在正常和测试编译中添加的 Espresso 依赖项

转载 作者:行者123 更新时间:2023-11-29 19:27:28 25 4
gpt4 key购买 nike

我需要为我的 android 应用程序开发仪器测试,我还需要为我的应用程序实现 IdlingResource 接口(interface),以便告诉 Espresso 该 Activity 处于空闲状态;所以我必须两次添加 Espresso 依赖项,一次在正常编译中,一次在测试编译中,如下所示:

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
[...]
compile('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude module: 'support-annotations'
}
androidTestCompile('com.android.support.test:runner:0.5') {
exclude module: 'support-annotations'
}
androidTestCompile('com.android.support.test:rules:0.5') {
exclude module: 'support-annotations'
}
// The following lib is already imported in a standard way, but needs to be imported again
// in the test environment.
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude module: 'support-annotations'
}
androidTestCompile('com.android.support.test.espresso:espresso-intents:2.2.2') {
exclude module: 'support-annotations'
}
[...]
}

但是正常编译应用程序是行不通的:

Error:Execution failed for task ':app:processDebugAndroidTestResources'.
> java.io.FileNotFoundException: [...]/app/build/intermediates/symbols/androidTest/debug/R.txt (No such file or directory)

我做错了什么吗?

最佳答案

build.gradle 中删除👇🏽:

compile('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude module: 'support-annotations'
}

参见 this ,您需要添加 compile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2' 而不是整个 Espresso-core lib。

关于android - 在正常和测试编译中添加的 Espresso 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40976486/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com