Warning:Conflict 依赖 'com.android.support:support-annotations' (25.0.1)

Warning:Conflict with dependency 'com.android.support:support-annotations' (25.0.1)

好的,我知道,类似的问题已经被问过好几次了,但我找不到解决我的问题的方法。 我需要测试我的应用程序。所以我按照教程告诉我添加 Android runnter 支持。

androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'

问题是,这似乎与我的兼容库不兼容。

compile 'com.android.support:appcompat-v7:25.0.1' 
compile 'com.android.support:design:25.0.1'

但是由于我们针对 API 级别 25 进行开发,因此需要这些库。所以我想回到版本 23 不是一个选项。

那么我怎样才能得到这个运行?我错过了什么吗?

androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'

参考旧版本supportAnnotations

com.android.support:support-annotations:23.1.1

您有几个选择:

  1. 明确声明 suportAnnotations 测试编译版本(覆盖任何传递依赖):

    androidTestCompile 'com.android.support:support-annotations:25.0.1'
    
  2. 从这些依赖项中排除它:

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