添加Firebase Messenger后出现Google Services插件版本冲突求助
Hey there, let's get that Firebase version conflict sorted out for you!
What's causing the issue?
The error message is pointing out a mismatch between your google-services plugin version and the Firebase dependencies you're using. Your project is running com.google.gms:google-services:3.2.1 (a relatively old version) alongside Firebase libraries at version 11.8.0—these two don't play nicely together. The plugin needs an update to support the newer Firebase versions.
How to fix it
Here's the step-by-step solution:
Update the google-services plugin in your project-level build.gradle
Open your top-levelbuild.gradlefile and replace the old plugin version with one compatible with Firebase 11.8.0. A safe, fully compatible choice here is version4.3.10:buildscript { repositories { jcenter() google() maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.google.gms:google-services:4.3.10' // Updated this line classpath 'io.fabric.tools:gradle:1.25.1' classpath 'com.google.firebase:firebase-plugins:1.1.5' } }Double-check your Firebase dependency consistency
Great news—you already have all your Firebase libraries set to11.8.0, which is perfect. Keeping all Firebase/Google Play Services dependencies on the same version is critical to avoid these conflicts, so no changes needed here.Confirm plugin placement
You already haveapply plugin: 'com.google.gms.google-services'at the very bottom of your app-levelbuild.gradle, which is the correct position (it needs to come after all your dependencies are declared). No adjustments required here either!
Final steps
After making these changes, sync your Gradle project and rebuild it. The version conflict error should disappear.
If you run into similar issues later, remember: the google-services plugin version must match the compatibility of your Firebase/Google Play Services libraries. Updating the plugin is almost always better than downgrading Firebase libraries (since you’ll keep access to new features and bug fixes).
内容的提问来源于stack exchange,提问作者ZeroKat

