dpa99c / cordova-plugin-request-location-accuracy

Cordova/Phonegap plugin for Android and iOS to request enabling/changing of Location Services by triggering a native dialog
96 stars 62 forks source link

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

Closed kaynz closed 7 years ago

kaynz commented 7 years ago

Hi,

I'm getting this error

Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin'] For input string: "+"

with the latest version of this plugin.

You can find more info about the problem here: https://github.com/phonegap/phonegap-plugin-push/issues/1718

dpa99c commented 7 years ago

This occurs due to a Gradle version collision with another plugin: this plugin specifies com.google.android.gms:play-services-location:+ in its plugin.xml.

The simplest solution is to install cordova-android-play-services-gradle-release into your project, which will force all plugins in the project (including this one) to use the same version of Play Services.

kaynz commented 7 years ago

Thanks. I'm getting the same error with cordova-android-play-services-gradle-release.

kaynz commented 7 years ago

I'm using latest phonegap-plugin-push, latest cordova. Everything up2date. I cleared node_modules, platforms, plugin and set up everything from fresh. Same problem. What information do you need to find the problem? :)

dpa99c commented 7 years ago

What information do you need to find the problem?

Time. I'm flat out with work.

Try also adding @christocracy's new plugin to your project:

cordova plugin add google-api-version --variable GOOGLE_API_VERSION=11.+
christocracy commented 7 years ago

I don't think there's a solution when some other plugin uses :+. That blows it up.

Other plugins should at least provide the major version, eg: :11.+. I had to do this for my background-geolocation-lt yesterday.

christocracy commented 7 years ago

Yes, the problem is here in this plugin. If that were changed to :11.+, it should work.

dpa99c commented 7 years ago

@christocracy The Gradle config in your Google API version plugin (and my Play Services and App Support plugins) should override any versions requested by other plugins via their Gradle config. At least, that's what I found in testing cordova-android-support-gradle-release.

I'm keenly aware that if every plugin author sets their version to 11.+ then the world will explode when Google releases 12.+ and the first plugin author makes that change. My hope was that our Gradle plugins could be used to override whatever is configured in a 3rd party plugin so as to not rely on the author to update it - in this case, me!

christocracy commented 7 years ago

It should. The problem is with plugins like phonegap-plugin-push which have to do stuff like this:

ext.postBuildExtras = {
    apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}

This isn't normally how GoogleServicesPlugin is installed in native apps. It's a hack to overcome the limitations of Cordova, which doesn't provide access to the global build.gradle.

christocracy commented 7 years ago

Normally, google-services-plugin should be installed in the root build.gradle like this:

apply plugin: 'com.google.gms.google-services'  // <-- string reference
dpa99c commented 7 years ago

ext.postBuildExtras = { apply plugin: com.google.gms.googleservices.GoogleServicesPlugin }

That's a bit evil. phonegap-plugin-push isn't one I have tested with this override mechanism, so I've been blissfully unaware of this scenario: the override has been working nicely for other plugins. It throws a bit a spanner in the Gradle override approach.

Ho hum, I'll try setting 11.+ for this one and see if it fixes the issue. At least that should fix it for @kaynz

christocracy commented 7 years ago

cordova-plugin-fcm as well.

dpa99c commented 7 years ago

OK, just tested locally and setting 11.+ does indeed work in this case.

@kaynz apologies, I wasn't aware of the Gradle hack used by phonegap-plugin-push as described by @christocracy.

Will push out a patch release that fixes this in a few minutes...

dpa99c commented 7 years ago

Published as cordova-plugin-request-location-accuracy@2.2.2

kaynz commented 7 years ago

Time. I'm flat out with work.

Sorry, I didn't mean to be rude.

@kaynz apologies, I wasn't aware of the Gradle hack used by phonegap-plugin-push as described by @christocracy.

I will have a look into https://github.com/dpa99c/cordova-android-play-services-gradle-release and phonegap-plugin-push. Maybe I can help you out with a fix for this problem.

Thanks for the workaround 👍

Genarito commented 5 years ago

Same problem, in my case It was a issue with Firebase plugin and Firebase-Messaging plugin, I solved with these instructions:

  1. Remove firebase plugin: ionic cordova plugin remove cordova-plugin-firebase && npm uninstall --save @ionic-native/firebase
  2. Remove plugin folder (important): rm -rf ./plugins
  3. Remove and add platform: ionic cordova platform remove android && ionic cordova platform add android

Hope It helps