Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']


#1

Getting following error while building,

A problem occurred evaluating root project ‘android’.
> Failed to apply plugin [class ‘com.google.gms.googleservices.GoogleServicesPlugin’]
> For input string: “+”


#2

Hello,
Have you resolved this issue? I’m getting the same error and been searching Google all day for solutions, but none of them helped. Even removing & re-adding Android & all plugins didn’t solve it.


#3

Change following code in project.properties from:

cordova.system.library.2=com.google.android.gms:play-services-gcm:+
cordova.system.library.3=com.google.android.gms:play-services-location:+
to

cordova.system.library.2=com.google.android.gms:play-services-gcm:11.0.1
cordova.system.library.3=com.google.android.gms:play-services-location:11.0.1
and add google-service.json file to app module


#4

Here the monster thread about that subject

Summarized, it depends from your cordova-android version and the plugins you are using

At first I would suggest to update to last cordova-android

Then try to find which plugins produce the error and double check that you are using the last version

I used to had this problem while using cordova-plugin-facebook4 and cordova.plugins.diagnostic, could confirm both of these plugins are now fixed


#5

Thanks for the tip.
Unfortunately, I don’t have those entries in my project.properties file. This is what I have in mine (replaced the app name with XXX)…


target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-base:+
cordova.system.library.2=com.google.android.gms:play-services-ads:+
cordova.gradle.include.1=cordova-plugin-firebase/XXX-build.gradle
cordova.gradle.include.2=cordova-plugin-hockeyapp/XXX-build.gradle
cordova.system.library.3=com.android.support:support-v4:24.1.1+
cordova.system.library.4=com.facebook.android:facebook-android-sdk:4.+
cordova.gradle.include.3=phonegap-plugin-push/XXX-push.gradle
cordova.system.library.5=com.google.gms:google-services:+
cordova.system.library.6=com.google.firebase:firebase-core:+
cordova.system.library.7=com.google.firebase:firebase-messaging:+
cordova.system.library.8=com.google.firebase:firebase-crash:+
cordova.system.library.9=com.google.firebase:firebase-config:+
cordova.system.library.10=com.google.android.gms:play-services-auth:+
cordova.system.library.11=com.google.android.gms:play-services-identity:+
cordova.system.library.12=com.android.support:support-v13:26.+
cordova.system.library.13=me.leolin:ShortcutBadger:1.1.17@aar
cordova.system.library.14=com.google.firebase:firebase-messaging:11.0.1

I tried replacing the “+” values with 11.0.1, but got the same error. The app uses Google plus login plugin, the push plugin, Firebase, and others. I’m guessing the Google-related plugins are crashing.


#6

Thanks, Reed.
I can confirm I have the newest cordova-android. I’m going through each plugin, and I thought that there was some sort of conflict with phonegap-plugin-push and firebase. I removed & added them, but still no luck.

.


#7

I use phonegap-plugin-push and don’t face conflict too

In the issue I listed above, someone wrote that, to find the problem, all support-v4:+ should be replaced
He then suggested to run grep -Rin -C5 'support-v4:+' ./plugins

Would you like to give a try?

I’m not the best when it comes to this I’ve to say, maybe you should post your question in the issue with your list of dependencies?


#8

Thanks for the feedback.
After trying all sorts of things, and growing gray hair in the process, I decided to remove phonegap-plugin-push altogether and try onesignal. Loving it so far.


#9

what i did solved my problem rather than changing random properties of project.properties, First check the error message “com.google.gms.googleservices.GoogleServicesPlugin” and after that change only those which have this “com.google.gms” in prefix remove + and add a specific version in my case i added 11.6.2 and also add google-services.json to platform/android .


#10

I tried the above but didn’t work for me.


#11

Check for this things in your project.

Version of google services so that they don’t conflict with each other.

cordova.system.library.6=com.google.firebase:firebase-core:10.2+
cordova.system.library.7=com.google.firebase:firebase-messaging:10.2+
cordova.system.library.8=com.google.firebase:firebase-crash:10.2+
cordova.system.library.9=com.google.firebase:firebase-config:10.2+
cordova.system.library.10=com.google.android.gms:play-services-auth:10.2+
cordova.system.library.11=com.google.android.gms:play-services-identity:10.2+

Fcm gradle

comment the line below

apply plugin com.google.gms.googleservices.GoogleServicesPlugin

Build.gradle

Add this line, after dependencies

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    ...
}

apply plugin com.google.gms.google-services

and lastly make sure to put google-services.json in project’s root folder.

This works for me.