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
Closed

Comments

@PasinduDineth
Copy link

@PasinduDineth 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
Copy link

@Adwich Adwich commented May 1, 2018

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

@ahmedXabdeen
Copy link

@ahmedXabdeen 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
Copy link

@code-by 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
Copy link

@24 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
Copy link

@Adwich 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
Copy link

@lech-code-monkey lech-code-monkey commented May 2, 2018

I have the same error:
wk7lmbqkqe5si lzlth 7 t

@PasinduDineth
Copy link
Author

@PasinduDineth 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
Copy link

@ma3dau 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
Copy link
Collaborator

@jgfidelis 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.

@harshaSenaratne
Copy link

@harshaSenaratne harshaSenaratne 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
Copy link

@x3388638 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
Copy link

@841660202 841660202 commented May 5, 2018

who tell me how to solve it?

@ma3dau
Copy link

@ma3dau 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
Copy link

@lech-code-monkey lech-code-monkey commented May 7, 2018

@x3388638Thanks a lot, you have solved my problem successful

@FidelisChimombe
Copy link

@FidelisChimombe FidelisChimombe commented May 7, 2018

@x3388638 thank you so much, you are life saver

@flyher
Copy link

@flyher flyher commented May 7, 2018

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

@sibelius
Copy link
Collaborator

@sibelius sibelius commented May 16, 2018

@pstanton
Copy link

@pstanton 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
Copy link

@kkusanagi 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
Copy link

@Enigma10 Enigma10 commented May 30, 2018

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

@mgiacopu
Copy link

@mgiacopu 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
Copy link

@mgiacopu 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
Copy link

@kk412027247 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
Copy link

@blogdaren blogdaren commented Jul 1, 2018

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

@bbeckk
Copy link

@bbeckk 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
Copy link
Contributor

@sospedra sospedra commented Sep 27, 2018

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

@gokujy
Copy link

@gokujy 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
Copy link

@gabrielbabierra 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
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet