android - 升级到 Espresso 2.1,现在出现依赖冲突

标签 android android-espresso

在设置 Espresso 2.1 和最新版本的 Android 测试支持库时,我在构建时遇到了下一个警告:

Confilct with dependency 'com.android.support:support-annotations'. Resolved versions for app and test app differ

我的build.gradle 文件是:

apply plugin: 'com.android.application'

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

dependencies {
    androidTestCompile 'com.android.support.test:runner:0.2'
    androidTestCompile 'com.android.support.test:rules:0.2'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.0'
}

最佳答案

实际上我找到了一个 existing issue :

we built against the old 22.0.0 and didn't upgrade to 22.1.0. The runner depends on com.android.support:support-annotations:22.0.0 which conflicts with the latest support library release (22.1.0)

我通过将以下行添加到我的依赖项列表来告诉 gradle 它需要解析哪个版本的支持注释:

androidTestCompile 'com.android.support:support-annotations:22.1.0'

警告消失了。

关于android - 升级到 Espresso 2.1,现在出现依赖冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29820879/

相关文章:

android - 强制 Espresso 不要等待进度

java - 如何在运行测试之前使异步作业的 JUnit4 "Wait"完成

android - 在 RecyclerView 上滑动测试片状

android - android文件夹(bin、xbin、sbin)之间的区别

android - 非法状态异常 : get field slot from row 0 col 3

android - 使用 -no-window 在模拟器中运行时测试检测进程崩溃

android - 如何在 Android 中为 Espresso 测试自定义 Jacoco

android - 如何更新 ImageView 中的位图

java - 在android中将书面文本发送到屏幕

android - 如何使用 volley 库访问 JsonArray 中的值