我尝试将推送通知与Firebase云消息传递和Cordova FCM一起使用。我的 google-services.json 位于根文件夹中,其中 config.xml 和 platforms / 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
}
不确定有什么问题,建议会有所帮助
答案 0 :(得分:2)
问题是您的Gradle配置中指定的GoogleServices插件版本存在冲突:
/plugins/cordova-plugin-fcm/scr/android/FCMPlugin.gradle
select t.booking_no,
t.Movie_name,
stuff( ( select ' / ' + t2.Guest_Name
from table_name t2
where t2.booking_no = t.booking_no
FOR XML PATH(''), TYPE).value('.', 'nvarchar(max)')
,1,3,'') as Guest_Name
from table_name t
group by t.booking_no, t.Movie_name
插件/科尔多瓦 - 载体 - 谷歌的服务/的build.gradle
com.google.gms:google-services:3.0.0
您需要解决此问题,以便版本匹配。