cmackay / google-analytics-plugin

Cordova Google Analytics Plugin for Android & iOS
Apache License 2.0
89 stars 43 forks source link

Incompatibility with phonegap-plugin-push #77

Closed jvjvjv closed 6 years ago

jvjvjv commented 7 years ago

Hi.

When both this plugin and the phonegap-plugin-push plugin are installed in the project, building to Android provides the following error message.

Error: /Development/Projects/PluginCompatTest/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.0.1.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I mention it here and not there as I believe this plugin is out of date, being updated seven months ago, whereas the latest release of the other plugin is a month ago.

jvjvjv commented 7 years ago

The issue occurs on @2.0.0-rc5 right now (and likely previous releases of 2.0.0). This issue isn't a priority requirement.

cmackay commented 7 years ago

I don't use the phonegap push plugin so I am not familiar with this issue. I have seen one other similar issue #72 but a workaround provided had hard coded versions in the gradle file which I don't want to be merged into master but maybe it will solve your problem. You might want to post to phonegap push plugin also and see if there are incompatibilities with other plugins also since I am sure many others are using google play services. If you find a standard solution that works, I welcome pull requests. If so, please reopen this issue. Thanks!

cmackay commented 7 years ago

Actually I'll leave it open in case others have a suggestion

jvjvjv commented 7 years ago

Then it may be a phonegap push plugin issue, but I have a feeling it's an issue caused by using Firebase, where google services must be a specific version, so either a) everyone has to update their plugins for this one, or b) phonegap push plugin has to post hackish workarounds for version 2+.

cmackay commented 7 years ago

The config this plugin uses for including google play services does not include a version which I would think would result in fewer version conflicts since no specific version is being required. So it is odd that a version incompatibility exists but obviously something is off when using with phonegap push plugin. I wish I had a better answer for you. Please let me know if you hear of any solution that might help resolve this. Thanks!

cmackay commented 7 years ago

seems similar https://github.com/fechanique/cordova-plugin-fcm/issues/90

petarov commented 7 years ago

IMO the problem is in neither the analytics nor in the push or fcm plugins, but in how Cordova handles plugin versioning in general. You see there may be many plugins in your project, all with different or specific version dependencies and it is totally unclear how to set a common version to all 3rd party plugins when building your Cordova project. I believe Cordova does not have a real answer to that at the moment, however I'd welcome a correction. ;)

That being said, here is one possible solution.

  1. Let's say you have a new project with empty plugins and platforms folders.
  2. Add both the plugins to your project, .e.g., cordova plugin add ...
  3. Do not add any platforms yet. Make sure the platforms/ directory is empty.
  4. Go to plugins/com.cmackay.plugins.googleanalytics/plugin.xml and change the following line:
    <framework src="com.google.android.gms:play-services-analytics:+" />

to

    <framework src="com.google.android.gms:play-services-analytics:11.0.1" />
  1. Now add the platform, e.g., cordova platform add android

Try this and see if the build gets any further.


EDIT: Why the 11.0.1? That's what phonegap-plugin-push seems to be using. Ah yeah, the whole rebranding of play-services to firebase from Google's side makes the whole mess even worse. 😉

cmackay commented 7 years ago

Thanks @petarov for your comments. I completely agree. I don't see this as something we can fix in this plugin. I appreciate your detailed notes for a potential workaround for users. :)

jvjvjv commented 7 years ago

Thanks for the advice, everyone. Sounds like I'll just branch this to "fix" it directly in my project for now. I'll leave it at your discretion to close or leave open.

cmackay commented 7 years ago

I'll leave it open and mark it wontfix. If someone does find a good way to resolve this, please post any suggestions here :) Thanks!

jvjvjv commented 7 years ago

@petarov I haven't even tried your suggestion yet (been out of time lately) but I fully believe your suggestion will work. I appreciate your detailed notes and potential workaround as well.

daniyalakhan commented 6 years ago

Did anybody find a solution to this problem? Every time a project is built, a change needs to be made in project.properties file and the version number of com.google.android.gms:play-services-analytics needs to be changed from + to 11.0.1. Is there any possible way to avoid making this change every time a project is built?

cmackay commented 6 years ago

I am not aware of any good solutions for it. If you find one, feel free to submit a PR. I am sure others would appreciate it.

petarov commented 6 years ago

@cmackay I think I got something. I'll open a PR to check with you.

cmackay commented 6 years ago

That looks like a good solution for this. I appreciate you submitting the PR. I should have it merged and released later on today. Thanks @petarov !

cmackay commented 6 years ago

The changes are now published in version 1.0.3. I tested it out a bit and things seem to be working well. Thanks again @petarov for making this change :)

petarov commented 6 years ago

Awesome! Cheers 🍻