Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find method google() for arguments [] on repository container #881

Closed
davidanaya opened this issue Sep 28, 2018 · 24 comments · Fixed by #882
Closed

Could not find method google() for arguments [] on repository container #881

davidanaya opened this issue Sep 28, 2018 · 24 comments · Fixed by #882

Comments

@davidanaya
Copy link

Describe the bug
Last version of the plugin causes an error when building the project in ionic.

To Reproduce
Create a blank ionic (v3) project.
ionic start cordova-firebase-plugin blank
Add the plugin

ionic cordova plugin add cordova-plugin-firebase
npm i @ionic-native/firebase

Build the app

ionic cordova build android --prod

Expected behavior
The project is build with no errors

Console Logs

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/yc00033/Documents/temp/cordova-firebase-plugin/platforms/android/build.gradle' line: 25

* What went wrong:
A problem occurred evaluating root project 'android'.

> Could not find method google() for arguments [] on repository container.

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

BUILD FAILED

Total time: 3.653 secs
Error: /Users/yc00033/Documents/temp/cordova-firebase-plugin/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Build file '/Users/yc00033/Documents/temp/cordova-firebase-plugin/platforms/android/build.gradle' line: 25

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

Plugin Version
cordova-plugin-firebase 2.0.2 "Google Firebase Plugin"

Additional context
I created a project to replicate the issue.

@soumak77
Copy link
Contributor

@briantq do you know why we add the google() repo to the gradle file? Looking at the Crashlytics guide, there is no google() repo shown, so I'm wondering why we even need to add it. Based on this comment, removing the line has shown to get the build working for others.

@soumak77
Copy link
Contributor

@briantq looking at this Crashlytics setup guide, it says to add the google() repo. However, the location of the google() repo is under allprojects and not under buildscript where it is currently being added. Perhaps that is the reason some are experiencing issues.

@Mykiee
Copy link

Mykiee commented Sep 28, 2018

@davidanaya for just workaround comment google() function from build.gradle file and after that it will work without build failure. @soumak77 looking forward to get it resolved.

@soumak77
Copy link
Contributor

@Mykiee could you verify whether adding the following to the gradle file works or not?

allprojects {
    repositories {
        google()
    }
}

@Mykiee
Copy link

Mykiee commented Sep 28, 2018

@soumak77 I need to add this method under allprojects, right? Please let me know how can I verify this if its working good. Also do I need to uncomment google() function commented previously in buildscript? As it is doing fine with the method.

soumak77 added a commit that referenced this issue Sep 28, 2018
@soumak77
Copy link
Contributor

I created PR #882 which removes the need to add google() to the repo list. The official guide doesn't add it so I'm thinking we don't even need it.

@soumak77
Copy link
Contributor

@davidanaya please install the plugin from master to verify this has been fixed

ionic cordova plugin add https://github.com/arnesson/cordova-plugin-firebase.git#master

@davidanaya
Copy link
Author

Works like a charm, @soumak77 thanks!

@Mykiee
Copy link

Mykiee commented Sep 28, 2018

Thanks @soumak77 :)

@briantq
Copy link
Contributor

briantq commented Sep 28, 2018

@soumak77 I don't like that we removed the required setup steps for Firebase. Since only @Mykiee and @davidanaya are the only ones experiencing the issue, I'd check to see if it's environmental. I did a quick Google search (only took 60 seconds) but it looks like the issue might be due to an older gradle version, react-native-camera/react-native-camera#1530 (comment) I think we might check to see if that resolved the issue. @Mykiee and @davidanaya, what version of gradle are you using for your projects?

@briantq briantq reopened this Sep 28, 2018
@soumak77
Copy link
Contributor

@briantq It seems to me that the build would fail if the goggle() repo was required, but it is listed in the setup guide so I guess it's needed....

In any case, looks like I'll need to revert my changes.

@davidanaya
Copy link
Author

@briantq it was failing with 4.1 and I updated to 4.6 and still was failing

@briantq
Copy link
Contributor

briantq commented Sep 28, 2018

@davidanaya do you have a gradle.properties located in platforms\android\gradle\wrapper? If so, can you paste the contents of that file please?

@davidanaya
Copy link
Author

I have a gradle-wrapper.properties file with these contents

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

@briantq
Copy link
Contributor

briantq commented Sep 28, 2018

Looks like you are using Gradle 3.3 for building your project. Check out these directions on how to upgrade your gradle version, https://blog.nishtahir.com/2018/04/15/how-to-properly-update-the-gradle-wrapper/ I am running 4.4. Based on the few stackoverflow posts I read, that should resolve your issue. You might consider upgrading your gradle version more often as 3.3 is well over a year and a half old...

@davidanaya
Copy link
Author

Thanks @briantq The thing is that this file is automatically generated by ionic (cordova) so even if I change it when I do the build it will be generated again with the wrong version; maybe the way to update gradle is by updating cordova itself (I'm using version 7.1.0) ? I upgraded gradle by android studio but it seems that this did not affect the version of gradle used in my project.

@guilhermegjr
Copy link

Hi everyone.
I was following this thread because I was with exactly same error. I'm using Ionic 3 and cordova-plugin-firebase.
I was using cordova android@6.3.0 and when I upgrade it to 6.4.0 I could build the project without problem.
@davidanaya can you try to build with this cordova-android version?

@davidanaya
Copy link
Author

Thanks @guilhermegjr I will try but I need to sync with my team as we are using the same Ionic version for a few different apps and we need to check if it does not break anything.
I'll report back on Monday.

@briantq
Copy link
Contributor

briantq commented Sep 29, 2018

@davidanaya interesting, I do not use Ionic so I was not aware. With this knowledge I would do 2 things:

  1. Create an issue against Ionic to upgrade to a release of Gradle that came out within the last year.
    1b. Submit a Pull Request against Ionic for the upgrade as it should be a pretty trivial change and unless Ionic has a lot of build plugins, there's a decent chance it just works.

  2. If you read the article I liked to, you will find that you upgrade the gradlew version by running gradlew. After Ionic prepares the platform, simply add one line to your script to upgrade gradlew to 4.1+ and it should work. Where ever you call your Ionic build script, add that one line and you should be good every time you recreate the platform from there on out.

@guilhermegjr Thanks for the pointer! @davidanaya, definitely let us know if you are able to confirm that does resolve the issue. Looking at the Cordova Android 6.4.0 Release Notes, they explicitly reference gradle and that they are removing it going forward. It sounds like that might be the issue.

@soumak77
Copy link
Contributor

I use ionic and I don't think it relies on a specific Gradle version. I suspect the Gradle version you have in your PATH is the old version and wasn't upgraded properly. Just a hunch.

@briantq
Copy link
Contributor

briantq commented Sep 29, 2018

The Gradle Wrapper was designed to be self contained. When Android started using Gradle it was not very familiar and no one had it installed. Hence they designed a self contained system that overrides the system gradle and installs a version if you elected. If you run ./gradle, it will use the system but ./gradlew will definitely run the version specified in the gradle.properties. Just depends on which command Ionic runs (and possible the 6.3.0 version as it seems like gradlew might have been removed completely in later releases).

@soumak77
Copy link
Contributor

Ionic relies on cordova for building the source. My app has cordova-android v7.1 and has the following line contained in node_modules/cordova-android/framework/gradle/wrapper/gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

Therefore I think if you upgrade your cordova-android version, this issue should be resolved.

@soumak77
Copy link
Contributor

soumak77 commented Oct 1, 2018

This appears to be resolved. You'll need to update your cordova-android version to get this fixed. I've modified our supported cordova versions to reflect this.

@soumak77 soumak77 closed this as completed Oct 1, 2018
@Akankshaagrawal13
Copy link

what is the solution of this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants