Firebase云消息传递FCM构建错误无法添加任务':processDebugGoogleServices'作为具有该名称的任务已存在
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Firebase云消息传递FCM构建错误无法添加任务':processDebugGoogleServices'作为具有该名称的任务已存在相关的知识,希望对你有一定的参考价值。
我正在尝试将推送通知与Firebase云消息传递和Cordova FCM一起使用。我的google-services.json位于根文件夹中,其中包含config.xml和platform / android /文件夹中的相同文件。随着离子cordova构建我得到错误:
配置根项目'android'时出现问题。
无法添加任务':processDebugGoogleServices'作为具有该名称的任务已存在。
我安装了:
cordova plugin add cordova-support-google-services --save
ionic cordova plugin add cordova-plugin-fcm
npm install --save @ionic-native/fcm
以前是另一个原因:
cordova插件添加cordova-plugin-googleplus ...
现在我得到了什么:
平台/安卓/科尔多瓦 - 插件-FCM / MYAPP-FCMPlugin.gradle:
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.0.0'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
平台/安卓/科尔多瓦支持,谷歌的服务/ MYAPP-的build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.2.0'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
ext.postBuildExtras = {
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}
平台/安卓/ project.properties:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-auth:11.0.1
cordova.system.library.2=com.google.android.gms:play-services-identity:11.0.1
cordova.system.library.3=com.facebook.android:facebook-android-sdk:4.14.+
cordova.system.library.4=com.google.firebase:firebase-core:+
cordova.system.library.5=com.google.firebase:firebase-messaging:11.0.1
cordova.gradle.include.1=cordova-plugin-fcm/myapp-FCMPlugin.gradle
cordova.gradle.include.2=cordova-support-google-services/myapp-build.gradle
这是从以下编辑:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-auth:+
cordova.system.library.2=com.google.android.gms:play-services-identity:+
cordova.system.library.3=com.facebook.android:facebook-android-sdk:4.14.+
cordova.system.library.4=com.google.firebase:firebase-core:+
cordova.system.library.5=com.google.firebase:firebase-messaging:+
cordova.gradle.include.1=cordova-plugin-fcm/myapp-FCMPlugin.gradle
platforms / android / build.gradle也被编辑为project.properties:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.google.android.gms:play-services-auth:11.0.1"
compile "com.google.android.gms:play-services-identity:11.0.1"
compile "com.facebook.android:facebook-android-sdk:4.14.+"
compile "com.google.firebase:firebase-core:+"
compile "com.google.firebase:firebase-messaging:11.0.1"
// SUB-PROJECT DEPENDENCIES END
}
插件/科尔多瓦 - 插件-FCM / SCR /安卓/ FCMPlugin.gradle:
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.0.0'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
插件/科尔多瓦支持 - 谷歌服务/的build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.2.0'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
ext.postBuildExtras = {
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}
不确定有什么问题,建议会有所帮助
问题是您在Gradle配置中指定了GoogleServices插件的冲突版本:
/plugins/Cordova-plugin-防沉迷/四川人/Android/F cm plugin.grad了
com.google.gms:google-services:3.0.0
插件/科尔多瓦支持,谷歌的服务/的build.gradle
com.google.gms:google-services:3.2.0
您需要解决此问题,以便版本匹配。
以上是关于Firebase云消息传递FCM构建错误无法添加任务':processDebugGoogleServices'作为具有该名称的任务已存在的主要内容,如果未能解决你的问题,请参考以下文章
Firebase 云消息传递 REST API Spring
如何使用 Nuxt.js 实现 Firebase 云消息传递 (FCM)