问题
I would like to add notification with firebase on my app. I followed a video on YouTube (https://www.youtube.com/watch?v=xx7hemn3FY4) But I have an error when I do the same thing in my flutter project : 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.
I tried several things as you can see in comment.
Project 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"
}
}
}
}
App 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'
But none of these changes works. Do you have an other idea ?
回答1:
I faced the similar issue, where in the error message it states that
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.
Resolved resolves to 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
}
I solved my isssue by adding the line
implementation 'com.google.firebase:firebase-core:11.8.0'. // <<--- Add this
Also if this doesn't fix the issue please add this line;
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
at the end of the same file like below;
...
dependencies {
....
}
....
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
Let me know if it solved our issue.
Thanks!
回答2:
This conflict happens because of using older libraries solution is use latest one. In my case i was using firebase version 16.0.0 , current latest is 16.0.4 (07-02-2019)
implementation 'com.google.firebase:firebase-core:16.0.0'
rather than this
implementation 'com.google.firebase:firebase-core:16.0.4'
回答3:
Check whether the firebase and other Google services are the same or not.
formimplementation 'com.google.android.gms:play-services-maps:16.0.0'
to
`implementation 'com.google.android.gms:play-services-maps:16.0.1'`
来源:https://stackoverflow.com/questions/51485608/the-library-com-google-android-gmsplay-services-basement-is-being-requested-by