問題:Conflict with dependency 'com.android.support:appcompat-v7' in project ':app'……

不同版本jar包衝突

as工程報如下錯誤:

Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:appcompat-v7' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

解決方案1:

在對應模塊的build.gradle文件中增加如下內容

configurations.all {
    //解決"Conflict with dependency 'com.android.supportsupport-annotations' in project 'app'"
    resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'
}

缺點:衝突幾個jar包需要配置幾個

解決方案2:

工程的.idea/libraries有相關jar的xml配置文件,刪除衝突的就ok了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章