繁体   English   中英

与依赖'com.android.support:support-annotations'冲突。 app(23.3.0)和测试app(23.1.1)的已解决版本有所不同

[英]Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.3.0) and test app (23.1.1) differ

我在为一个Android项目添加espresso时遇到了这个异常。 我已经尝试了此异常附带的链接

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

我也根据我找到的其他帖子添加以下行

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

但问题仍然存在。 我使用以下配置:

buildToolsVersion "23.0.2"

androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'

任何想法,谢谢。

这解决了问题'应用程序的解析版本(24.0.0-beta1)和测试应用程序(23.0.1)对我来说不同。

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

如果您想运行AndroidTest,请不要忘记添加以下代码

 defaultConfig {
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dependencies {
    //...

    // Solves "versions for app (23.3.0) and test app (23.1.1) differ"
    androidTestCompile 'com.android.support:support-annotations:23.3.0'

    // Android JUnit Runner
    androidTestCompile 'com.android.support.test:runner:0.5'
    // JUnit4 Rules
    androidTestCompile 'com.android.support.test:rules:0.5'
}

现在,当您在Android Studio上创建新项目时,默认情况下会添加此依赖项:

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

exclude部分可能是为了避免问题中提到的冲突。 在尝试添加runner:0.5rules:0.5依赖项时,我也遇到了这个问题。 我的解决方案是在上面应用相同的代码:

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

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

这个对我有用。 希望能帮助到你。

注释库被所有三个依赖规则使用:0.5',runner:05和espresso-core:2.2.2,所以以下为我工作

androidTestCompile 'com.android.support.test:runner:0.5', {
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile 'com.android.support.test:rules:0.5', {
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
}

重建项目解决了这个问题。

在Android工作室的工作室中.. Build> Rebuild Project。

сompile 'com.android.support:support-annotations:23.3.0'
androidTestCompile ("com.android.support.test:runner:0.5"){
   exclude group: 'com.android.support'
}
androidTestCompile ('com.android.support.test:rules:0.5'){
   exclude group: 'com.android.support'
}

这是一个解决方案

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM