Saturday, January 26, 2019

Could not find method google() for arguments [] on repository container In React Native

Sometime during the mobile application development using react native library, you have seen this "Could not find method google() for arguments [] on repository container" error message in your console or terminal. This is a most common type comparability issues in react native application for that you need to either downgrade the library version or else you need to upgrade your Android project gradle version.

Lets see below real time example, where we have installed Realm library in react native application and we are using react native version 0.54 for application development. But during compilation we are getting below error message in console.

FAILURE: Build failed with an exception.

* Where:
Build file '~/myprj/node_modules/react-native-camera/android/build.gradle' line: 4

* What went wrong:
A problem occurred evaluating project ':realm'.
> 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.


Solution we have modified below details in react native project folder :

Step-1:- Open file and modify the distributionUrl section as per below

After modification file structure should look like this :

Step-2:-  Add the below highlighted line in your build.gradle file and provide the updated gradle version in dependencies section.
Top level build.gradle is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
    dependencies {
        classpath ''

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

allprojects {
    repositories {
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"

Follow the mentioned steps, this may fixed your problem in react native application.

1 comment:

  1. it works for me on android studio...same instruction was follow