FCMPlugin build fail due to version conflict with google gms services

安稳与你 提交于 2019-11-30 15:36:43

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

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.

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

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
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!