其他分享
首页 > 其他分享> > android-升级到Espresso 2.1,现在出现依赖冲突

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

作者:互联网

在设置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,android
来源: https://codeday.me/bug/20191120/2043958.html