AS 解決support-annotations版本衝突

一個Gradle support-annotations版本衝突的坑,報錯如下:

  • What went wrong:
    Execution failed for task ‘:testAppForMobile:lint’.

Could not resolve all artifacts for configuration ‘:testAppForMobile:debugAndroidTestRuntimeClasspath’.
Could not resolve com.android.support:support-annotations:26.0.0.
Required by:
project :testAppForMobile
Cannot find a version of ‘com.android.support:support-annotations’ that satisfies the version constraints:
Dependency path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support.test🏃1.0.2’ --> ‘com.android.support:support-annotations:27.1.1’
Dependency path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support:appcompat-v7:26.0.0’ --> ‘com.android.support:support-annotations:26.0.0’
Dependency path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support.test🏃1.0.2’ --> ‘com.android.support.test:monitor:1.0.2’ --> ‘com.android.support:support-annotations:27.1.1’
Dependency path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support.test.espresso:espresso-core:3.0.2’ --> ‘com.android.support.test🏃1.0.2’ --> ‘com.android.support:support-annotations:27.1.1’
Dependency path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support:leanback-v17:26.0.0’ --> ‘com.android.support:support-compat:26.0.0’ --> ‘com.android.support:support-annotations:26.0.0’
Dependency path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support:leanback-v17:26.0.0’ --> ‘com.android.support:support-core-ui:26.0.0’ --> ‘com.android.support:support-annotations:26.0.0’
Dependency path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support:leanback-v17:26.0.0’ --> ‘com.android.support:support-media-compat:26.0.0’ --> ‘com.android.support:support-annotations:26.0.0’
Dependency path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support:leanback-v17:26.0.0’ --> ‘com.android.support:recyclerview-v7:26.0.0’ --> ‘com.android.support:support-annotations:26.0.0’
Dependency path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support:appcompat-v7:26.0.0’ --> ‘com.android.support:support-vector-drawable:26.0.0’ --> ‘com.android.support:support-annotations:26.0.0’
Dependency path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support:leanback-v17:26.0.0’ --> ‘com.android.support:support-fragment:26.0.0’ --> ‘com.android.support:support-core-utils:26.0.0’ --> ‘com.android.support:support-annotations:26.0.0’
Constraint path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support:support-annotations’ strictly ‘26.0.0’ because of the following reason: debugRuntimeClasspath uses version 26.0.0
Constraint path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support:support-annotations’ strictly ‘26.0.0’ because of the following reason: debugRuntimeClasspath uses version 26.0.0

搞了半天,一直說是找不到com.android.support:support-annotations:26.0.0.
Dependency path ‘Stb_Application:testAppForMobile:unspecified’ --> ‘com.android.support:appcompat-v7:26.0.0’ --> 'com.android.support:support-annotations:26.0.0’這裏又說不確定是哪個版本的,原來是依賴的項目裏的jar包用的是不同版本的,解決的辦法就是在依賴的模塊和自己的模塊中加入
configurations.all {
resolutionStrategy.force ‘com.android.support:support-annotations:26.0.0’
},強制使用這個版本的,就解決了。

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