与依赖项“com.android.support:支持注释”冲突

与依赖项“com.android.support:支持注释”冲突,android,unit-testing,android-testing,android-instrumentation,Android,Unit Testing,Android Testing,Android Instrumentation,我正在尝试为我的应用程序设置检测单元测试。我在下面的开发者网站链接上添加了依赖项 这是我的依赖列表 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

我正在尝试为我的应用程序设置检测单元测试。我在下面的开发者网站链接上添加了依赖项

这是我的依赖列表

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'
}
当我构建项目时,我得到以下编译错误:

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.

任何人都可以帮助我解决这个问题。

注释是支持库的一部分。所以,您的注释和支持库版本应该相同,您必须使用下面的代码强制调用。此代码应该放在依赖项之上。有关更多详细信息,请参阅


我已更改为21.0.3,现在我收到以下错误:与依赖项“com.android.support:support annotations”“in project”:MyApp冲突。app 21.0.3和测试app 23.1.1的解析版本有所不同。有关详细信息,请参阅。
configurations.all {
  resolutionStrategy {
    force 'com.android.support:support-annotations:21.0.3'
  }
}