Android 与firebase 11.8.0和google服务插件3.1.2冲突
我与firebase 11.8.0和google服务插件3.1.2有明显的冲突。建议改用firebase的11.4.2版,但构建失败 my gradle构建文件的相关摘录: RootAndroid 与firebase 11.8.0和google服务插件3.1.2冲突,android,firebase,gradle,google-play-services,gradle-plugin,Android,Firebase,Gradle,Google Play Services,Gradle Plugin,我与firebase 11.8.0和google服务插件3.1.2有明显的冲突。建议改用firebase的11.4.2版,但构建失败 my gradle构建文件的相关摘录: Rootbuild.gradle buildscript { repositories { google() ... } dependencies { classpath 'com.google.gms:google-services:3.1.2'
build.gradle
buildscript {
repositories {
google()
...
}
dependencies {
classpath 'com.google.gms:google-services:3.1.2'
...
}
}
应用程序build.gradle
:
apply plugin: 'com.google.gms.google-services'
repositories {
google()
....
}
dependencies {
implementation "com.google.firebase:firebase-core:11.8.0"
....
}
我已正确生成firebase应用程序文件:
./app/src/debug/google-services.json
./app/src/release/google-services.json
当我使用/gradlew clean assembleDebug
生成时,生成失败,出现以下错误:
> Task :app:processDebugGoogleServices FAILED
Found com.google.firebase:firebase-core:11.8.0, but version 11.4.2 is needed for the google-services plugin.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.4.2.
解决方案是将此行移动到app
build.gradle
文件的底部(不应位于顶部):
文件中对此进行了规定:
然后,在模块Gradle文件(通常是app/build.Gradle)中添加
文件底部的apply plugin行用于启用渐变
插件:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:11.8.0'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:11.8.0'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'