Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react native camera Gradle sync failed: Could not find method google() for arguments [] on repository container

I am trying to install react-native-camera.

I did npm install react-native-camera react-native link react-native-camera.

It gives me the error saying Gradle sync failed: Could not find method google() for arguments [] on repository container.

I tried manual link too as stated in the documentation till step 6 where I added

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
    }
}

I used exifinterface versions, e.g. 27.+ instead of 25.+

I have distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip as distributionUrl and classpath 'com.android.tools.build:gradle:2.2.3'

I dont know what am I missing. When I open my android studio it gives me error Gradle sync failed: Could not find method google() for arguments [] on repository container

And when I run react-native run-android on my phone it gives me error saying undefined is not an object (evaluating 'cameramanager.aspect')

Can anyone help me what am I missing here ??

Here is my gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'

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

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}
like image 831
Green Eagle Avatar asked May 03 '18 09:05

Green Eagle


2 Answers

You could try to upgrade your gradle (android\build.gradle) to this version

classpath 'com.android.tools.build:gradle:3.0.1'

to do so you would also need to upgrade the android/gradle/wrapper/gradle-wrapper.properties

from

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

to

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

This solved a similar problem for me.

like image 74
MaximumLasagna Avatar answered Oct 29 '22 16:10

MaximumLasagna


Change your gradle-wrapper distribution url to

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
like image 2
Arthur Attout Avatar answered Oct 29 '22 16:10

Arthur Attout