gpt4 book ai didi

android - Firebase Cloud Messaging FCM 构建错误无法添加任务 ':processDebugGoogleServices',因为该名称的任务已存在

转载 作者:太空狗 更新时间:2023-10-29 13:05:14 26 4
gpt4 key购买 nike

我正在尝试将推送通知与 Firebase 云消息传递和 Cordova FCM 结合使用。我的 google-services.jsonconfig.xml 位于根文件夹中,同一文件位于 platforms/android/ 文件夹中。使用 ionic cordova build 我得到了错误:

A problem occurred configuring root project 'android'.

Cannot add task ':processDebugGoogleServices' as a task with that name already exists.

我已经安装了:

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 ...

现在我得到了:

platforms/android/cordova-plugin-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

platforms/android/cordova-support-google-services/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
}

平台/android/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
}

plugins/cordova-plugin-fcm/scr/android/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

plugins/cordova-support-google-services/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-fcm/scr/android/FCMPlugin.gradle

com.google.gms:google-services:3.0.0

plugins/cordova-support-google-services/build.gradle

com.google.gms:google-services:3.2.0

您需要解决此问题以便版本匹配。

关于android - Firebase Cloud Messaging FCM 构建错误无法添加任务 ':processDebugGoogleServices',因为该名称的任务已存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49204867/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com