适用于Android(25.3.1)和测试应用(23.1.1)错误的Android Espresso Framework已解决版本

时间:2017-07-15 11:40:53

标签: android android-espresso

当我尝试通过gradle添加espresso库时收到此错误消息。我该如何解决?

2 个答案:

答案 0 :(得分:2)

问题是espresso使用旧版本的支持库而不是你。由于您已经拥有了项目,因此请将它们从浓咖啡中排除。 因此,在build.gradle文件中,您应该替换:

androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'

with:

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

如果您有更多冲突,请尝试排除更多支持模块(例如appcompat,design等)。

答案 1 :(得分:1)

使用此代码测试recyclelerview

等操作
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2', {

    exclude group: 'com.android.support', module: 'appcompact'
    exclude group: 'com.android.support', module: 'support-v4'
    exclude group: 'com.android.support', module: 'support-annotations'
    exclude module: 'recyclerview-v7'
})

或者使用

compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'appcompact'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'support-annotations'
exclude module: 'recyclerview-v7'
    })