当我尝试通过gradle添加espresso库时收到此错误消息。我该如何解决?
答案 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'
})