Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.3.0) and test app (23.1.1) differ

后端 未结 6 1374
挽巷
挽巷 2020-12-31 00:42

I came across this exception while adding espresso to an android project. I already try the link that comes with this exception

**Conflict with dependency \'         


        
相关标签:
6条回答
  • 2020-12-31 01:00

    Rebuild project solved the issue.

    In Android studio in the toolbar.. Build>Rebuild Project.

    0 讨论(0)
  • 2020-12-31 01:07
    dependencies {
        //...
    
        // Solves "versions for app (23.3.0) and test app (23.1.1) differ"
        androidTestCompile 'com.android.support:support-annotations:23.3.0'
    
        // Android JUnit Runner
        androidTestCompile 'com.android.support.test:runner:0.5'
        // JUnit4 Rules
        androidTestCompile 'com.android.support.test:rules:0.5'
    }
    
    0 讨论(0)
  • 2020-12-31 01:10

    annotation library is used by all three dependancies rules:0.5', runner:05 and espresso-core:2.2.2, so following worked for me

    androidTestCompile 'com.android.support.test:runner:0.5', {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestCompile 'com.android.support.test:rules:0.5', {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    
    0 讨论(0)
  • 2020-12-31 01:14

    This solve the problem 'Resolved versions for app (24.0.0-beta1) and test app (23.0.1) differ' for me.

    android{    
        configurations.all {
            resolutionStrategy.force 'com.android.support:support-annotations:23.0.1'
        }
    }
    

    And do not forget to add following code, if you want to run the AndroidTest

     defaultConfig {
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    
    0 讨论(0)
  • 2020-12-31 01:17

    Nowadays when you create a new project on Android Studio, it adds this dependency by default:

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

    The exclude section is probably to avoid the conflict mentioned in the question. I also faced this issue when trying to add runner:0.5 and rules:0.5 dependencies. My solution was to apply the same piece of code above on them:

    androidTestCompile ('com.android.support.test:runner:0.5', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    
    androidTestCompile ('com.android.support.test:rules:0.5', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    

    It works for me. Hope it helps.

    0 讨论(0)
  • 2020-12-31 01:24
    сompile 'com.android.support:support-annotations:23.3.0'
    androidTestCompile ("com.android.support.test:runner:0.5"){
       exclude group: 'com.android.support'
    }
    androidTestCompile ('com.android.support.test:rules:0.5'){
       exclude group: 'com.android.support'
    }
    

    It's a solution

    0 讨论(0)
提交回复
热议问题