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

后端 未结 9 1078
臣服心动
臣服心动 2020-11-28 21:38

When building I get the following error:

Conflict with dependency \'com.android.support:support-annotations\'. Resolved versions for app (23.1.0) and test a         


        
相关标签:
9条回答
  • 2020-11-28 22:05

    In my case, I added below code in dependencies of app level build.gradle

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

    After that, I clean the project and rebuild.My problem solved.

    0 讨论(0)
  • 2020-11-28 22:09

    you can try to use

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

    instead of

    androidTestCompile 'com.android.support.test:runner:0.4.1'
    
    androidTestCompile 'com.android.support.test:rules:0.4.1'
    
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
    
    0 讨论(0)
  • 2020-11-28 22:10

    Chang your application level build.gradle file's:

    implementation 'com.android.support:appcompat-v7:23.1.0'

    to

     implementation 'com.android.support:appcompat-v7:23.0.1'
    
    0 讨论(0)
  • 2020-11-28 22:17

    I was getting the same error today:

    Error:Execution failed for task ':app:preDebugAndroidTestBuild'.> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ.

    What I did:

    • I simply updated all my dependencies to 27.1.1 instead of 26.1.0
    • Also, updated my compileSdkVersion 27 and targetSdkVersion 27 which were 26 earlier

    And com.android.support:support-annotations error was gone!

    For Ref:

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.0'
        implementation 'com.android.support:design:27.1.1'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    }
    
    0 讨论(0)
  • 2020-11-28 22:19

    Project Rebuild solved my problem.

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

    0 讨论(0)
  • 2020-11-28 22:22

    You can force the annotation library in your test using:

    androidTestCompile 'com.android.support:support-annotations:23.1.0'
    

    Something like this:

      // Force usage of support annotations in the test app, since it is internally used by the runner module.
      androidTestCompile 'com.android.support:support-annotations:23.1.0'
      androidTestCompile 'com.android.support.test:runner:0.4.1'
      androidTestCompile 'com.android.support.test:rules:0.4.1'
      androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
      androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1'
      androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.1'
    

    Another solution is to use this in the top level file:

    configurations.all {
        resolutionStrategy.force 'com.android.support:support-annotations:23.1.0'
    }
    
    0 讨论(0)
提交回复
热议问题