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’
},强制使用这个版本的,就解决了。

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