簡體   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