简体   繁体   中英

Conflict with dependency 'com.android.support:support-annotations'

I am trying to set up an Instrumented Unit Tests for my App. and I have added dependency based on the below developer site link.

https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests.html#build

This is my dependency list

dependencies {
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:support-v4:21.0.3'
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.10.19'
    androidTestCompile 'com.android.support:support-annotations:24.0.0'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test:rules:0.5'
}

When I build the project I am getting the below compile error:

Error:Conflict with dependency 'com.android.support:support-annotations' in project ':MyApp'. Resolved versions for the app (21.0.3) and test app (24.0.0) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

Could anyone please help me to resolve this issue.

Annotations is the part of Support library. So,your annotations and support library version Should be same and you have to call forcefully by using below code .This code should be placed above dependencies.For more detail See here

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

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