FCMPlugin build fail due to version conflict with google gms services

后端 未结 5 1404
无人及你
无人及你 2021-01-03 06:45

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:



        
5条回答
  •  甜味超标
    2021-01-03 07:01

    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
    }
    

提交回复
热议问题