库 com.google.android.gms:play-services-basement 正在被 [[15.0.1,15.0.1]] 上的各种其他库请求,但解析为 11.8.0

The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 11.8.0

我想在我的应用程序中添加带有 firebase 的通知。 我在 YouTube 上关注了一个视频 (https://www.youtube.com/watch?v=xx7hemn3FY4) 但是当我在我的 flutter 项目中做同样的事情时我有一个错误:[[15.0.1,15.0.1]] 上的各种其他库正在请求库 com.google.android.gms:play-services-basement,但是解析为 11.8.0。禁用插件并使用 ./gradlew :app:dependencies.

检查你的依赖关系树

如您在评论中所见,我尝试了几种方法。

项目 gradle :

 buildscript {
    repositories {
        google()
        jcenter()
    }

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'

    classpath 'com.google.gms:google-services:4.0.1'
    //classpath 'com.google.gms:google-services:4.0.0'

}
}

allprojects {
    repositories {
        google()
        jcenter()
        /*
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
        */
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

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

        }
    }
}

应用Gradle:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 27

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.weatherapp"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    //Implementation 'com.google.android.gms:play-services-basement:15.0.1'
    //Implementation 'com.google.firebase:firebase-core:15.0.0'
}

apply plugin: 'com.google.gms.google-services'

但是 none 这些更改有效。你有别的想法吗?

我遇到了类似的问题,在错误消息中指出

The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 11.8.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

已解决 已解决至 11.8.0

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    //Implementation 'com.google.android.gms:play-services-basement:15.0.1'
    //Implementation 'com.google.firebase:firebase-core:15.0.0'

   implementation 'com.google.firebase:firebase-core:11.8.0'.  // <<--- Add this
}

我通过添加行

解决了我的问题
implementation 'com.google.firebase:firebase-core:11.8.0'.  // <<--- Add this

此外,如果这不能解决问题,请添加此行;

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

在同一个文件的末尾,如下所示;

...

dependencies {
  ....
}

....

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

如果它解决了我们的问题,请告诉我。

谢谢!

检查 firebase 和其他 Google 服务是否相同。

形式
implementation 'com.google.android.gms:play-services-maps:16.0.0'

`implementation 'com.google.android.gms:play-services-maps:16.0.1'`

发生此冲突是因为使用较旧的库解决方案是使用最新的。 就我而言,我使用的是 firebase 版本 16.0.0,当前最新版本是 16.0.4 (07-02-2019)

 implementation 'com.google.firebase:firebase-core:16.0.0'

而不是这个

 implementation 'com.google.firebase:firebase-core:16.0.4'