我正在尝试为我的应用程序设置仪器单元测试。我根据以下开发人员网站链接添加了依赖性。
https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests.html#build
这是我的依赖列表
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.
任何人都可以帮我解决这个问题。
注释是支持库的一部分。因此,您的注释和支持库版本应该相同,您必须使用以下代码强烈致电。该代码应放置在依赖项上方。有关更多详细信息,请参见此处
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:21.0.3'
}
}