简体   繁体   中英

Android Espresso Framework Resolved versions for app (25.3.1) and test app (23.1.1) Error

I'am getting this error message when I try to add espresso libraries by gradle. How can I fix it ?

Problem is that espresso uses older versions of support libraries than you are. Since you already have then in your project, exclude them from espresso. So, in your build.gradle file, you should replace:

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'
})

If you have more conflicts, try excluding more support modules (like appcompat, design etc).

use this code for testing actions like 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'
})

or else use

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'
    })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM