arnesson / cordova-plugin-firebase

Cordova plugin for Google Firebase
http://arnesson.github.io/cordova-plugin-firebase
MIT License
1.01k stars 1.56k forks source link

Google Gradle dependency added even if it already exists #893

Open brendoncoin opened 6 years ago

brendoncoin commented 6 years ago

Describe the bug google() is added to the build.gradle file of the project using this pluging, even if the maven repo is already declared.

To Reproduce Steps to reproduce the behavior:

  1. Build an Android app that has cordova-plugin-firebase and already includes the googe maven repo in it's gradle file because of other dependencies.
  2. The build.gradle file can end up with something like this:
    google() // Google's Maven repository from cordova-plugin-firebase
    maven { url 'https://maven.fabric.io/public' } // Fabrics Maven repository from cordova-plugin-firebase
    maven {
    url "https://maven.google.com"
    }

Expected behavior google() is only added if there is no reference to the dependency already.

Screenshots NA

Console Logs NA

Plugin Version 2.0.2

Smartphone (please complete the following information):

Additional context NA.

briantq commented 6 years ago

@brendoncoin does that cause problems?

Shared dependencies are a tough situation. What should the plugin do when it's removed? Should it remove the gradle() reference? How does it know that another plugin isn't referencing it? Removing that could cause problems with existing scripts. If it doesn't remove it, it could leave garage after it's gone.

The solution we've elected is to mark our dependencies so we only modify the ones we add so we dont dirty a project nor break existing scripts. If you have a smarter approach, I'm definitely interested in hearing it.

brendoncoin commented 6 years ago

It's causing us problems, mainly because it's inserting google(), which is not compatible with our current build and we already have maven { url "https://maven.google.com" }. Since you mark the ones you add with a comment containing cordova-plugin-firebase, then perhaps just don't remove google() if it doesn't have that comment next to it?

spandy47 commented 5 years ago

I'm having same Error while adding Cordova-plugin-firebase with ionic. Did there any resolution? Build file '/Users/abc/Workspace/myApp/platforms/android/build.gradle' line: 46

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find method google() for arguments [] on repository container.

I'm using: Cordova - 7.0.1 ionic - 3.10.3 "cordova-plugin-firebase": "^2.0.5" "@ionic-native/firebase": "^4.19.0"

spandy47 commented 5 years ago

Resolved it. Had to upgrade android platform and built again. Requires android@6.4.0 for cordova-plugin-firebase 2.0.5