Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved vers

經常在新建項目或者導入別的項目時遇到這個問題,真是煩死大爺了,記錄一下。

Error:FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (27.0.2) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s

解決方案:在app級別目錄下(非project目錄)的build.gradle中添加:

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

在這裏插入圖片描述

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