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 #1530

Closed
PasinduDineth opened this Issue May 1, 2018 · 29 comments

Comments

Projects
None yet
@PasinduDineth
Copy link

PasinduDineth commented May 1, 2018

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.

@Adwich

This comment has been minimized.

Copy link

Adwich commented May 1, 2018

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

@ahmedXabdeen

This comment has been minimized.

Copy link

ahmedXabdeen commented May 1, 2018

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

This comment has been minimized.

Copy link

code-by commented May 1, 2018

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

This comment has been minimized.

Copy link

24 commented May 1, 2018

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()
    }
}


@sibelius sibelius closed this May 1, 2018

@Adwich

This comment has been minimized.

Copy link

Adwich commented May 2, 2018

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

This comment has been minimized.

Copy link

lech-code-monkey commented May 2, 2018

I have the same error:
wk7lmbqkqe5si lzlth 7 t

@PasinduDineth

This comment has been minimized.

Copy link
Author

PasinduDineth commented May 2, 2018

@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

This comment has been minimized.

Copy link

ma3dau commented May 2, 2018

@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

This comment has been minimized.

Copy link
Collaborator

jgfidelis commented May 2, 2018

@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

This comment has been minimized.

@velvetrain

This comment has been minimized.

Copy link

velvetrain commented May 4, 2018

@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

This comment has been minimized.

Copy link

x3388638 commented May 4, 2018

@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

This comment has been minimized.

Copy link

841660202 commented May 5, 2018

who tell me how to solve it?

@ma3dau

This comment has been minimized.

Copy link

ma3dau commented May 5, 2018

I solve it, but maybe I have some specific case of use. I use react-native-camera as part of react-native-qrcode-scanner, so I don't need to take a picture and other camera functionality. For me helped @24 solution, but next error "different version for the compile" I couldn't solve with @x3388638 suggestions. My solution for app/build.gradle is:

compile (project(':react-native-camera')) {
      exclude group: "com.android.support", module: 'support-v4'
}

my modules version is same as @x3388638.
my top level build.grande is:

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

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        google()
        maven {
           url "$rootDir/../node_modules/react-native/android"
        }
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
        google()
    }
}

gradle/wrapper/gradle-wrapper.properties

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

app/build.gradle

...
android {
	compileSdkVersion 25
	buildToolsVersion "25.0.2"
...
dependencies {
    compile (project(':react-native-camera')) {
       exclude group: "com.android.support", module: 'support-v4'
    }
}

If excluding com.android.support is a bad way and will be a better solution I'll try it. For my issue (reading barcodes) this setup works as well.

@lech-code-monkey

This comment has been minimized.

Copy link

lech-code-monkey commented May 7, 2018

@x3388638Thanks a lot, you have solved my problem successful

@FidelisChimombe

This comment has been minimized.

Copy link

FidelisChimombe commented May 7, 2018

@x3388638 thank you so much, you are life saver

@flyher

This comment has been minimized.

Copy link

flyher commented May 7, 2018

@x3388638 the code doesn't work and build failed
@ma3dau build success but i got the white screen

@sibelius

This comment has been minimized.

Copy link
Member

sibelius commented May 16, 2018

@pstanton

This comment has been minimized.

Copy link

pstanton commented May 24, 2018

I've managed to get it working by making numerous changes some listed here, others found all over the web. I also use react-native-maps which has conflicting requirements. This is a major problem and requires immediate attention.

@kkusanagi

This comment has been minimized.

Copy link

kkusanagi commented May 24, 2018

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

This comment has been minimized.

Copy link

Enigma10 commented May 30, 2018

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

@mgiacopu

This comment has been minimized.

Copy link

mgiacopu commented May 30, 2018

@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

This comment has been minimized.

Copy link

mgiacopu commented May 30, 2018

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

@kk412027247

This comment has been minimized.

Copy link

kk412027247 commented Jun 22, 2018

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

This comment has been minimized.

Copy link

blogdaren commented Jul 1, 2018

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

@bbeckk

This comment has been minimized.

Copy link

bbeckk commented Jul 18, 2018

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

This comment has been minimized.

Copy link
Contributor

sospedra commented Sep 27, 2018

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

@gokujy

This comment has been minimized.

Copy link

gokujy commented Dec 7, 2018

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

This comment has been minimized.

Copy link

gabrielbabierra commented Jan 20, 2019

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
You can’t perform that action at this time.