I\'m using this with ionic 2 on Windows for Android. When I add cordova-plugin-fcm plugin, I cannot build the project anymore. Here is the error that I\'m getting:
I came across this thread, in case this is helpful to anyone, here are the set of files and changes I made so that my android client would build fine. I was having a conflict with cordova-plugin-fcm and cordova-plugin-googleplus. Here is a
platforms/android/build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// I added this:
classpath 'com.google.gms:google-services:3.1.0'
}
..
allprojects {
repositories {
// changed the + to 10.2.0
compile "com.google.android.gms:play-services-auth:10.2.0"
compile "com.google.android.gms:play-services-identity:10.2.0"
}
}
// at end of the promptForReleaseKeyPassword function, add this:
def promptForReleaseKeyPassword() {
...
apply plugin: 'com.google.gms.google-services'
}
android/project.properties (Changed + to 10.2.0)
cordova.system.library.3=com.google.android.gms:play-services-auth:10.2.0
cordova.system.library.4=com.google.android.gms:play-services-identity:10.2.0
cordova-plugin-fcm/mobile-FCMPlugin.gradle (this file was a tricky one)
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.1.0'
}
...
// apply plugin: 'com.google.gms.google-services' moved into this postBuildExtras function.
// 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
}
I had the same issue. It turned out I had phonegap-plugin-push and cordova-plugin-fcm installed. They were causing the conflict. I had to remove one of them. Credits to: https://github.com/fechanique/cordova-plugin-fcm/issues/90#issuecomment-243435681
Something wierd happened for me, when i remove the google-maps plugin, build the project and run it on my device, everything worked perfectly and all the maps loaded just fine.
I solved it.
plugings:
https://github.com/mauron85/cordova-plugin-background-geolocation
https://github.com/fechanique/cordova-plugin-fcm
1). remove platform: cordova platform rm android.
2). modify: plugins/cordova-plugin-fcm/src/android/FCMPlugin.gradle
replace:
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
with:
ext.postBuildExtras = {
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}
3) add platform: cordova platform add android.
4) modify: platforms/android/project.properties
change the "+" for "11.4.2":
com.google.firebase:firebase-core:+
com.google.firebase:firebase-messaging:+
com.google.android.gms:play-services-location:+
should look like this:
com.google.firebase:firebase-core:11.4.2
com.google.firebase:firebase-messaging:11.4.2
com.google.android.gms:play-services-location:11.4.2
that's all :).
To resolve this error, go to the Project-->platform..>android-->.gradlefile and Modify the line
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.0.0' //change this line
}
} // 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