所有com.android.support库必须使用完全相同的版本规范28.0.0和26.1.0

时间:2019-05-03 19:16:30

标签: android gradle dependencies

我知道这里曾被问过100次,我已经检查了类似的问题,但仍然无法解决。

就我而言,Android Studio说:

  

所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本28.0.0,26.1.0。示例包括com.android.support:animated-vector-drawable:28.0.0和com.android.support:support-media-compat:26.1.0

所以我检查了Gradle依赖树:

+--- com.android.support.test:runner:1.0.2
|    +--- com.android.support:support-annotations:27.1.1 -> 28.0.0
|    +--- com.android.support.test:monitor:1.0.2
|    |    \--- com.android.support:support-annotations:27.1.1 -> 28.0.0
|    +--- junit:junit:4.12
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    \--- net.sf.kxml:kxml2:2.3.0
+--- com.android.support.test.espresso:espresso-core:3.0.2
|    +--- com.android.support.test:runner:1.0.2 (*)
|    +--- com.android.support.test.espresso:espresso-idling-resource:3.0.2
|    +--- com.squareup:javawriter:2.1.1
|    +--- javax.inject:javax.inject:1
|    +--- org.hamcrest:hamcrest-library:1.3
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    +--- org.hamcrest:hamcrest-integration:1.3
|    |    \--- org.hamcrest:hamcrest-library:1.3 (*)
|    \--- com.google.code.findbugs:jsr305:2.0.1
+--- com.android.support.test:runner:{strictly 1.0.2} -> 1.0.2 (c)
+--- com.android.support:support-annotations:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support.test:monitor:{strictly 1.0.2} -> 1.0.2 (c)
+--- junit:junit:{strictly 4.12} -> 4.12 (c)
+--- org.hamcrest:hamcrest-core:{strictly 1.3} -> 1.3 (c)
+--- net.sf.kxml:kxml2:{strictly 2.3.0} -> 2.3.0 (c)
+--- com.android.support.test.espresso:espresso-core:{strictly 3.0.2} -> 3.0.2 (c)
+--- com.android.support.test.espresso:espresso-idling-resource:{strictly 3.0.2} -> 3.0.2 (c)
+--- com.squareup:javawriter:{strictly 2.1.1} -> 2.1.1 (c)
+--- javax.inject:javax.inject:{strictly 1} -> 1 (c)
+--- org.hamcrest:hamcrest-library:{strictly 1.3} -> 1.3 (c)
+--- org.hamcrest:hamcrest-integration:{strictly 1.3} -> 1.3 (c)
+--- com.google.code.findbugs:jsr305:{strictly 2.0.1} -> 2.0.1 (c)
+--- com.android.support:appcompat-v7:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-compat:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:collections:{strictly 28.0.0} -> 28.0.0 (c)
+--- android.arch.lifecycle:runtime:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.lifecycle:common:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.core:common:{strictly 1.1.1} -> 1.1.1 (c)
+--- com.android.support:versionedparcelable:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:cursoradapter:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-core-utils:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:documentfile:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:loader:{strictly 28.0.0} -> 28.0.0 (c)
+--- android.arch.lifecycle:livedata:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.core:runtime:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.lifecycle:livedata-core:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.lifecycle:viewmodel:{strictly 1.1.1} -> 1.1.1 (c)
+--- com.android.support:localbroadcastmanager:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:print:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-fragment:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-core-ui:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:customview:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:viewpager:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:coordinatorlayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:drawerlayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:slidingpanelayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:interpolator:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:swiperefreshlayout:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:asynclayoutinflater:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:support-vector-drawable:{strictly 28.0.0} -> 28.0.0 (c)
+--- com.android.support:animated-vector-drawable:{strictly 28.0.0} -> 28.0.0 (c)
+--- android.arch.persistence.room:runtime:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.persistence.room:common:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.persistence:db-framework:{strictly 1.1.1} -> 1.1.1 (c)
+--- android.arch.persistence:db:{strictly 1.1.1} -> 1.1.1 (c)
+--- com.nostra13.universalimageloader:universal-image-loader:{strictly 1.9.5} -> 1.9.5 (c)
+--- org.jetbrains:annotations-java5:{strictly 15.0} -> 15.0 (c)
+--- pub.devrel:easypermissions:{strictly 2.0.1} -> 2.0.1 (c)
+--- org.locationtech.jts:jts:{strictly 1.16.1} -> 1.16.1 (c)
+--- com.mapbox.mapboxsdk:mapbox-android-navigation:{strictly 0.34.0} -> 0.34.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-services:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-core:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.google.code.gson:gson:{strictly 2.8.5} -> 2.8.5 (c)
+--- com.squareup.retrofit2:retrofit:{strictly 2.4.0} -> 2.4.0 (c)
+--- com.squareup.okhttp3:okhttp:{strictly 3.14.1} -> 3.14.1 (c)
+--- com.squareup.okio:okio:{strictly 1.17.2} -> 1.17.2 (c)
+--- com.squareup.retrofit2:converter-gson:{strictly 2.4.0} -> 2.4.0 (c)
+--- com.squareup.okhttp3:logging-interceptor:{strictly 3.11.0} -> 3.11.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-geojson:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-sdk-turf:{strictly 4.5.0} -> 4.5.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-android-core:{strictly 1.2.0} -> 1.2.0 (c)
+--- com.mapbox.mapboxsdk:mapbox-android-telemetry:{strictly 4.2.0} -> 4.2.0 (c)
+--- android.arch.lifecycle:extensions:{strictly 1.1.0} -> 1.1.0 (c)
+--- com.mapbox.navigator:mapbox-navigation-native:{strictly 6.1.0} -> 6.1.0 (c)
+--- com.jakewharton.timber:timber:{strictly 4.7.1} -> 4.7.1 (c)
+--- com.google.android.gms:play-services-location:{strictly 16.0.0} -> 16.0.0 (c)
+--- com.google.android.gms:play-services-base:{strictly 16.0.1} -> 16.0.1 (c)
+--- com.google.android.gms:play-services-basement:{strictly 16.0.1} -> 16.0.1 (c)
+--- com.android.support:support-v4:{strictly 26.1.0} -> 26.1.0 (c)
+--- com.android.support:support-media-compat:{strictly 26.1.0} -> 26.1.0 (c)
+--- com.google.android.gms:play-services-tasks:{strictly 16.0.1} -> 16.0.1 (c)
+--- com.google.android.gms:play-services-places-placereport:{strictly 16.0.0} -> 16.0.0 (c)
+--- com.android.support:appcompat-v7:28.0.0
|    +--- com.android.support:support-annotations:28.0.0
|    +--- com.android.support:support-compat:28.0.0
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:collections:28.0.0
|    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    +--- android.arch.lifecycle:runtime:1.1.1
|    |    |    +--- android.arch.lifecycle:common:1.1.1
|    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    +--- android.arch.core:common:1.1.1
|    |    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    \--- com.android.support:versionedparcelable:28.0.0
|    |         +--- com.android.support:support-annotations:28.0.0
|    |         \--- com.android.support:collections:28.0.0 (*)
|    +--- com.android.support:collections:28.0.0 (*)
|    +--- com.android.support:cursoradapter:28.0.0
|    |    \--- com.android.support:support-annotations:28.0.0
|    +--- com.android.support:support-core-utils:28.0.0
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    +--- com.android.support:documentfile:28.0.0
|    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:loader:28.0.0
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- android.arch.lifecycle:livedata:1.1.1
|    |    |    |    +--- android.arch.core:runtime:1.1.1
|    |    |    |    |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    |    |    |    \--- android.arch.core:common:1.1.1 (*)
|    |    |    |    +--- android.arch.lifecycle:livedata-core:1.1.1
|    |    |    |    |    +--- android.arch.lifecycle:common:1.1.1 (*)
|    |    |    |    |    +--- android.arch.core:common:1.1.1 (*)
|    |    |    |    |    \--- android.arch.core:runtime:1.1.1 (*)
|    |    |    |    \--- android.arch.core:common:1.1.1 (*)
|    |    |    \--- android.arch.lifecycle:viewmodel:1.1.1
|    |    |         \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    +--- com.android.support:localbroadcastmanager:28.0.0
|    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    \--- com.android.support:print:28.0.0
|    |         \--- com.android.support:support-annotations:28.0.0
|    +--- com.android.support:support-fragment:28.0.0
|    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    +--- com.android.support:support-core-ui:28.0.0
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    |    +--- com.android.support:customview:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:viewpager:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:coordinatorlayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:drawerlayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:slidingpanelayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:customview:28.0.0 (*)
|    |    |    +--- com.android.support:interpolator:28.0.0
|    |    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:swiperefreshlayout:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:interpolator:28.0.0 (*)
|    |    |    +--- com.android.support:asynclayoutinflater:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    \--- com.android.support:support-compat:28.0.0 (*)
|    |    |    \--- com.android.support:cursoradapter:28.0.0 (*)
|    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:loader:28.0.0 (*)
|    |    \--- android.arch.lifecycle:viewmodel:1.1.1 (*)
|    +--- com.android.support:support-vector-drawable:28.0.0
|    |    +--- com.android.support:support-annotations:28.0.0
|    |    \--- com.android.support:support-compat:28.0.0 (*)
|    \--- com.android.support:animated-vector-drawable:28.0.0
|         +--- com.android.support:support-vector-drawable:28.0.0 (*)
|         \--- com.android.support:support-core-ui:28.0.0 (*)
+--- android.arch.persistence.room:runtime:1.1.1
|    +--- android.arch.persistence.room:common:1.1.1
|    |    \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    +--- android.arch.persistence:db-framework:1.1.1
|    |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    |    \--- android.arch.persistence:db:1.1.1
|    |         \--- com.android.support:support-annotations:26.1.0 -> 28.0.0
|    +--- android.arch.persistence:db:1.1.1 (*)
|    +--- android.arch.core:runtime:1.1.1 (*)
|    \--- com.android.support:support-core-utils:26.1.0 -> 28.0.0 (*)
+--- com.nostra13.universalimageloader:universal-image-loader:1.9.5
+--- org.jetbrains:annotations-java5:15.0
+--- pub.devrel:easypermissions:2.0.1
|    +--- com.android.support:appcompat-v7:28.0.0 (*)
|    +--- com.android.support:support-compat:28.0.0 (*)
|    \--- com.android.support:support-fragment:28.0.0 (*)
+--- org.locationtech.jts:jts:1.16.1
+--- com.mapbox.mapboxsdk:mapbox-android-navigation:0.34.0
|    +--- com.mapbox.mapboxsdk:mapbox-sdk-services:4.5.0
|    |    +--- com.mapbox.mapboxsdk:mapbox-sdk-core:4.5.0
|    |    |    +--- com.google.code.gson:gson:2.8.5
|    |    |    +--- com.squareup.retrofit2:retrofit:2.4.0
|    |    |    |    \--- com.squareup.okhttp3:okhttp:3.10.0 -> 3.14.1
|    |    |    |         \--- com.squareup.okio:okio:1.17.2
|    |    |    +--- com.squareup.retrofit2:converter-gson:2.4.0
|    |    |    |    +--- com.squareup.retrofit2:retrofit:2.4.0 (*)
|    |    |    |    \--- com.google.code.gson:gson:2.8.2 -> 2.8.5
|    |    |    \--- com.squareup.okhttp3:logging-interceptor:3.11.0
|    |    |         \--- com.squareup.okhttp3:okhttp:3.11.0 -> 3.14.1 (*)
|    |    \--- com.mapbox.mapboxsdk:mapbox-sdk-geojson:4.5.0
|    |         \--- com.google.code.gson:gson:2.8.5
|    +--- com.mapbox.mapboxsdk:mapbox-sdk-turf:4.5.0
|    |    +--- com.mapbox.mapboxsdk:mapbox-sdk-core:4.5.0 (*)
|    |    \--- com.mapbox.mapboxsdk:mapbox-sdk-geojson:4.5.0 (*)
|    +--- com.mapbox.mapboxsdk:mapbox-android-core:1.2.0
|    +--- com.mapbox.mapboxsdk:mapbox-android-telemetry:4.2.0
|    |    +--- com.squareup.okhttp3:okhttp:3.10.0 -> 3.14.1 (*)
|    |    +--- com.google.code.gson:gson:2.8.2 -> 2.8.5
|    |    \--- android.arch.lifecycle:extensions:1.1.0
|    |         +--- android.arch.lifecycle:runtime:1.1.0 -> 1.1.1 (*)
|    |         +--- android.arch.core:common:1.1.0 -> 1.1.1 (*)
|    |         +--- android.arch.core:runtime:1.1.0 -> 1.1.1 (*)
|    |         +--- com.android.support:support-fragment:26.1.0 -> 28.0.0 (*)
|    |         +--- android.arch.lifecycle:common:1.1.0 -> 1.1.1 (*)
|    |         +--- android.arch.lifecycle:livedata:1.1.0 -> 1.1.1 (*)
|    |         \--- android.arch.lifecycle:viewmodel:1.1.0 -> 1.1.1 (*)
|    +--- com.mapbox.navigator:mapbox-navigation-native:6.1.0
|    +--- com.android.support:appcompat-v7:28.0.0 (*)
|    \--- com.jakewharton.timber:timber:4.7.1
+--- com.squareup.okhttp3:okhttp:3.14.1 (*)
\--- com.google.android.gms:play-services-location:16.0.0
    +--- com.google.android.gms:play-services-base:16.0.1
    |    +--- com.google.android.gms:play-services-basement:16.0.1
    |    |    \--- com.android.support:support-v4:26.1.0
    |    |         +--- com.android.support:support-compat:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-media-compat:26.1.0
    |    |         |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
    |    |         |    \--- com.android.support:support-compat:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-core-utils:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-core-ui:26.1.0 -> 28.0.0 (*)
    |    |         \--- com.android.support:support-fragment:26.1.0 -> 28.0.0 (*)
    |    \--- com.google.android.gms:play-services-tasks:16.0.1
    |         \--- com.google.android.gms:play-services-basement:16.0.1 (*)
    +--- com.google.android.gms:play-services-basement:16.0.1 (*)
    +--- com.google.android.gms:play-services-places-placereport:16.0.0
    |    \--- com.google.android.gms:play-services-basement:16.0.1 (*)
    \--- com.google.android.gms:play-services-tasks:16.0.1 (*)

这个输出让我很困惑。似乎com.android.support.test:runner:1.0.2需要com.android.support:support-v4:{strictly 26.1.0},但是我找不到比提到的库1.0.2更高的版本。同时也需要com.android.support:appcompat-v7:{strictly 28.0.0}。所以它基本上需要两个版本的同一个库? 我真的不确定要怎么考虑,更不用说解决它了。请帮助:D

这是我的build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.sanctusmedia.android.WattsUp"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "0.07"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'org.jetbrains:annotations-java5:15.0'

    // Room persistence library (https://developer.android.com/training/data-storage/room/index.html#java)
    implementation "android.arch.persistence.room:runtime:1.1.1"
    annotationProcessor "android.arch.persistence.room:compiler:1.1.1"

    // https://github.com/nostra13/Android-Universal-Image-Loader, Apache 2.0 license
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

    // Easy permissions: https://github.com/googlesamples/easypermissions, Apache 2.0 license
    implementation 'pub.devrel:easypermissions:2.0.1'

    // JTS Topology Suite - predecessor of GEOS: https://github.com/locationtech/jts, EDL v1.0 license
    implementation group: 'org.locationtech.jts', name: 'jts', version: '1.16.1', ext: 'pom'

    // MapBox, see: https://www.mapbox.com
    implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.34.0'

    // OkHTTP, see: https://github.com/square/okhttp, Apache 2.0 license
    implementation("com.squareup.okhttp3:okhttp:3.14.1")

    // Google Play services for faster GPS lock
    implementation 'com.google.android.gms:play-services-location:16.0.0'
}

configurations {
    cleanedAnnotations
    compile.exclude group: 'org.jetbrains' , module:'annotations'
}

5 个答案:

答案 0 :(得分:0)

26.1.0版中的播放服务(support-v4)似乎需要play-services-location,而其他版本28的游戏服务都不需要implementation "com.android.support:support-v4:28.0.0" ,因此它不会自动升级。

如果您自己添加以下内容,会发生什么情况?

{{1}}

答案 1 :(得分:0)

几乎我们所有人(AS中的Android开发人员)都遇到相同的问题!我搜索了一下,最后放弃了,告诉自己这是android的另一个错误,与我无关!

最后,我将这一行添加到我的依赖项中来获得警告!

implementation "com.android.support:support-media-compat:28.0.0"

现在我使用 androidX ,并且此问题不再发生。

答案 2 :(得分:0)

问题是由于

implementation 'com.google.android.gms:play-services-location:16.0.0'

如果删除此行,则表示依赖关系正常。

\--- com.google.android.gms:play-services-location:16.0.0
     +--- com.google.android.gms:play-services-base:16.0.1
     |    +--- com.google.android.gms:play-services-basement:16.0.1
     |    |    \--- com.android.support:support-v4:26.1.0
     |    |         +--- com.android.support:support-compat:26.1.0 -> 28.0.0 (*)
     |    |         +--- com.android.support:support-media-compat:26.1.0
     |    |         |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
     |    |         |    \--- com.android.support:support-compat:26.1.0 -> 28.0.0 (*)
     |    |         +--- com.android.support:support-core-utils:26.1.0 -> 28.0.0 (*)
     |    |         +--- com.android.support:support-core-ui:26.1.0 -> 28.0.0 (*)
     |    |         \--- com.android.support:support-fragment:26.1.0 -> 28.0.0 (*)
     |    \--- com.google.android.gms:play-services-tasks:16.0.1
     |         \--- com.google.android.gms:play-services-basement:16.0.1 (*)
     +--- com.google.android.gms:play-services-basement:16.0.1 (*)
     +--- com.google.android.gms:play-services-places-placereport:16.0.0
     |    \--- com.google.android.gms:play-services-basement:16.0.1 (*)
     \--- com.google.android.gms:play-services-tasks:16.0.1 (*)

答案 3 :(得分:0)

您可以执行以下步骤。

  1. 找出支持库版本强制更改依赖项
  2. 使用implementation命令
  3. exclude这些lib,这将使您实现主要依赖关系并排除设置的组。
  4. 手动implementation具有特定版本的支持库。
  5. 执行此操作后,您可以再次打印依赖关系树,并检查相同依赖关系中的支持库版本。将其与非exclude一个进行比较

例如

例如1

+--- com.android.support.test:runner:1.0.2
|    +--- com.android.support:support-annotations:27.1.1 -> 28.0.0
|    +--- com.android.support.test:monitor:1.0.2
|    |    \--- com.android.support:support-annotations:27.1.1 -> 28.0.0
|    +--- junit:junit:4.12
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    \--- net.sf.kxml:kxml2:2.3.0

根据您发布的依赖关系树。

com.android.support.test:runner:1.0.2依赖com.android.support:support-annotations:27.1.1,并且支持库版本强制更改为28.0.0,您可以像下面那样进行操作。

implementation ('com.android.support.test:runner:1.0.2'){
        exclude group: 'com.android.support'
}

implementation 'com.android.support:support-annotations:28.0.0'

exclude命令可以排除您设置的group,然后手动implementation支持版本28.0.0的lib。

例如2

\--- com.google.android.gms:play-services-location:16.0.0
    +--- com.google.android.gms:play-services-base:16.0.1
    |    +--- com.google.android.gms:play-services-basement:16.0.1
    |    |    \--- com.android.support:support-v4:26.1.0
    |    |         +--- com.android.support:support-compat:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-media-compat:26.1.0
    |    |         |    +--- com.android.support:support-annotations:26.1.0 -> 28.0.0
    |    |         |    \--- com.android.support:support-compat:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-core-utils:26.1.0 -> 28.0.0 (*)
    |    |         +--- com.android.support:support-core-ui:26.1.0 -> 28.0.0 (*)
    |    |         \--- com.android.support:support-fragment:26.1.0 -> 28.0.0 (*)
    |    \--- com.google.android.gms:play-services-tasks:16.0.1
    |         \--- com.google.android.gms:play-services-basement:16.0.1 (*)
    +--- com.google.android.gms:play-services-basement:16.0.1 (*)
    +--- com.google.android.gms:play-services-places-placereport:16.0.0
    |    \--- com.google.android.gms:play-services-basement:16.0.1 (*)
    \--- com.google.android.gms:play-services-tasks:16.0.1 (*)

在这种情况下

implementation ('com.google.android.gms:play-services-location:16.0.0'){
        exclude group: 'com.android.support'
}

implementation 'com.android.support:support-core-utils:28.0.0'
implementation 'com.android.support:support-compat:28.0.0'

我没有列出所有情况,只是遵循我认为可能会有所帮助的规则!

答案 4 :(得分:0)

这是在依赖性解析期间覆盖的替代解决方案。您可以将以下代码段放在根级别build.gradle中:

buildscript {
    // ...
    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                        && !details.requested.name.contains('multidex') ) {
                    details.useVersion "28.0.0"
                }
            }
        }
    }
}