Skip to content
This repository was archived by the owner on Jun 16, 2023. It is now read-only.
This repository was archived by the owner on Jun 16, 2023. It is now read-only.

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

Closed
@PasinduDineth

Description

@PasinduDineth

Hi all,
I am having this error after i install react native camera. Can anyone help me. I have changed build.gradle dependency classpath to 3 also. But nothing is working. Any ideas?
error -
A problem occurred evaluating project ':react-native-camera'.

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

Activity

Adwich

Adwich commented on May 1, 2018

@Adwich

What version of react, react-native and react-native-camera do you use ?

ghost

ghost commented on May 1, 2018

@ghost

Hi, @Adwich
I'm running through this same issue, my react and react-native versions are:

react-native-cli: 2.0.1
react-native: 0.55.3
react: 16.3.1
react-native-camera: 1.1.2

code-by

code-by commented on May 1, 2018

@code-by

same issue
react-native-cli: 2.0.1
react-native: 0.55.3
react-native-camera: 1.1.2

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 ':react-native-camera'.
> 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
24

24 commented on May 1, 2018

@24

set gradle-wrapper.properties

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

set build.gradle

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

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

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

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


Adwich

Adwich commented on May 2, 2018

@Adwich

I got the problem using react-native 0.55.0 . Try downgrading react-native. I'm using react-native 0.53.3 and react-native-camera 1.0.3 without problem.

lech-code-monkey

lech-code-monkey commented on May 2, 2018

@lech-code-monkey

I have the same error:
wk7lmbqkqe5si lzlth 7 t

PasinduDineth

PasinduDineth commented on May 2, 2018

@PasinduDineth
Author

@24 after editing as you told, im getting this error,
Android dependency 'com.android.support:support-v4' has different version for the compile (23.0.1) and runtime (27.1.0) classpath. You should manually set the same version via DependencyResolution
any help?

ma3dau

ma3dau commented on May 2, 2018

@ma3dau

@PasinduDineth it can be solved by excluding "com.android.support" from react-native-camera implementation in /android/app/build.gradle

implementation (project(':react-native-camera')) {
        exclude group: "com.android.support"
}
jgfidelis

jgfidelis commented on May 2, 2018

@jgfidelis
Collaborator

@ma3dau Beware that if you exclude the support lib and not add it for compilation correctly on the build.gradle, your app will crash when taking a picture.

code-by

code-by commented on May 2, 2018

@code-by
harshaSenaratne

harshaSenaratne commented on May 4, 2018

@harshaSenaratne

@PasinduDineth
This worked for me : Make sure your react native version first , if you are using react-native < 0.40 then
npm install --save react-native-camera@0.4. If react-native > 0.40 then do npm install --save react-native-camera@0.6 . Link the react-native-camera using react-native link react-native-camera

  • Follow the steps below after linking.

    • in node_modules\react-native-camera\index.js
      1. removed PropTypes from import React, { Component, PropTypes } from 'react';
      2. add import PropTypes from 'prop-types';
  • in package.json.
    1. add in "dependencies" "prop-types": "^15.6.0"

x3388638

x3388638 commented on May 4, 2018

@x3388638

@PasinduDineth
I use the code @24 provided but get the same problem
however it was solved by adding the following code in android/build.gradle

subprojects {
  project.configurations.all {
     resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'
              && !details.requested.name.contains('multidex') ) {
           details.useVersion "27.1.0"
        }
     }
  }
}

and changing compileSdkVersion & buildToolsVersion in android/app/build.gradle

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.0"
    ...

finally, it works

modules version

{
    "react": "16.3.1",
    "react-native": "0.55.3",
    "react-native-camera": "^1.1.2",
    "react-native-qrcode-scanner": "^1.0.1",
}
841660202

841660202 commented on May 5, 2018

@841660202

who tell me how to solve it?

6 remaining items

kkusanagi

kkusanagi commented on May 24, 2018

@kkusanagi

I'm using react-native-camera@0.10 version for com.android.tools.build:gradle:2.2.+ which is quite stable for that version.

Once update the gradle, build version, react-native-camera, build.gradle, the whole system just crash. and don't know how to fix it. Really need some technical support / advice on how to upgrade properly.

By following android official migrate steps, only fix the latest react-native version, but for other plugin, all just crash.

Anyone who can create a blog about how to upgrade version would be helpful.

Enigma10

Enigma10 commented on May 30, 2018

@Enigma10

Hey Guys , My error got fixed with combination of @24 and @x3388638 solutions. :) .

mgiacopu

mgiacopu commented on May 30, 2018

@mgiacopu

@ma3dau your changes make the app compile but when I try to open the scanner it crashes without errors... I still don't get why the first error showed up.

mgiacopu

mgiacopu commented on May 30, 2018

@mgiacopu

Instead, a combination of @24 and @x3388638 codes gives the final solution.
Now it works like a charm.
Thank you guys! Thumbs up!

kk412027247

kk412027247 commented on Jun 22, 2018

@kk412027247

Combine @24 and @x3388638 codes, than I get a final solution.
I make a combine edition here,

android/build.gradle

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

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'

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

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        google()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

ext {
    buildToolsVersion = "26.0.3"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}

subprojects {

 project.configurations.all {
    resolutionStrategy.eachDependency { details ->
       if (details.requested.group == 'com.android.support'
              && !details.requested.name.contains('multidex') ) {
           details.useVersion "26.1.0"
        }
     }
  }

  afterEvaluate {project ->
      if (project.hasProperty("android")) {
          android {
              compileSdkVersion rootProject.ext.compileSdkVersion
              defaultConfig {
                  targetSdkVersion rootProject.ext.targetSdkVersion
              }
          }
      }
  }
}

android/gradle/wrapper/gradle-wrapper.properties

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

android/app/build.gradle

android{
  compileSdkVersion rootProject.ext.compileSdkVersion
  buildToolsVersion rootProject.ext.buildToolsVersion
    defaultConfig{
      
      minSdkVersion rootProject.ext.minSdkVersion
      targetSdkVersion rootProject.ext.targetSdkVersion  
      .....
    }
  .....
}

ADDITION
If your project has other android package like react-native-image-picker, when you run ./gradlew assembleRelease, you probably get a error AAPT: resource android:attr/colorError not found.
In order to fix this, you should make sure the compile version of the package match to your project.
The following code do this work.

    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                defaultConfig {
                    targetSdkVersion rootProject.ext.targetSdkVersion
                }
            }
        }
    }

MORE
If you get a error : uncompiled PNG file passed as argument. Must be compiled first into .flat file.. error: failed parsing overlays.

modify ./android/gradle.properties, add the following code.

android.enableAapt2=false

-> click here to get my project example <-

blogdaren

blogdaren commented on Jul 1, 2018

@blogdaren

@kk412027247 tks for your final solution with combination @24 and @x3388638 codes, it really works well.

bbeckk

bbeckk commented on Jul 18, 2018

@bbeckk

This solves the issue: https://github.com/react-native-community/react-native-camera/blob/master/docs/GradleUpgradeGuide.md

However it gives an warning but build is successful.

WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, 
as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.
Android SDK Build Tools 27.0.3 will be used.
sospedra

sospedra commented on Sep 27, 2018

@sospedra
Contributor

@kk412027247 comment should be on the official docs! Many thanks! Saved my day <3

gokujy

gokujy commented on Dec 7, 2018

@gokujy

I am getting the same error:
Could not find method google() for arguments [] on repository container
Solve: I'm working on firebase crud and i installed angularfire2 and firebase plugin both.
So i uninstall firebase and error solved, i mean this error coming because conflict.

gabrielbabierra

gabrielbabierra commented on Jan 20, 2019

@gabrielbabierra

Anyone have the same issue as mine after @kk412027247 's compiled edition changes. I have a build succesful but when i run my terminal i have an error:

Bundling index.android.js [development, non-minified] 0.0% (0/1), failed.
error: bundling failed: Error: Couldn't find preset "module:metro-react-native-babel-preset" relative to directory "/Users/Cyberland/Desktop/AttApp"

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kkusanagi@24@sibelius@sospedra@blogdaren

        Issue actions

          Could not find method google() for arguments [] on repository container · Issue #1530 · react-native-camera/react-native-camera