2017-07-15 79 views
0

我尝试通过gradle添加espresso库时遇到此错误消息。我该如何解决它?Android Espresso Framework解决了应用程序(25.3.1)和测试应用程序(23.1.1)的版本错误

+0

欢迎StackOverflow上。请参考[tour](http://stackoverflow.com/tour)浏览并阅读[帮助中心](http://stackoverflow.com/help),然后阅读[如何提问] (http://stackoverflow.com/help/how-to-ask),[我应该避免问什么类型的问题?](http://stackoverflow.com/help/dont-ask)并提供[MCVE:最小,完整和可验证示例](http://stackoverflow.com/help/mcve)。如果周围的人可以轻松阅读和理解你的意思,或者是什么问题,他们会更乐意帮助:) – Dwhitz

回答

2

问题是,espresso使用较旧版本的支持库,而不是您自己。既然你已经在你的项目中,将它们排除在特浓咖啡之外。 所以,在你的build.gradle文件,则应更换:

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

有:

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

如果您有更多的冲突,尽量排除更多的支持模块(如程序兼容性,设计等)。

+0

感谢您的评论我用你的方式解决了问题:) –

1

使用此代码进行测试操作,如recyclerview

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' 
    }) 
相关问题