反应原生相机Gradle sync失败:无法在存储库容器上找到方法google()for arguments []

时间:2018-05-03 09:41:13

标签: android react-native gradle react-native-android react-native-camera

我正在尝试安装react-native-camera

我做了npm install react-native-camera react-native link react-native-camera

它给出了错误Gradle sync failed: Could not find method google() for arguments [] on repository container

我也按照文档中的说明尝试了手动链接,直到第6步我添加了

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

我使用了exifinterface个版本,例如27.而不是25。+

我有distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip作为distributionUrl和classpath 'com.android.tools.build:gradle:2.2.3'

我不知道我错过了什么。当我打开我的android工作室时,它给了我错误Gradle sync failed: Could not find method google() for arguments [] on repository container

当我在手机上运行react-native run-android时,它会误给我undefined is not an object (evaluating 'cameramanager.aspect')

任何人都可以帮助我,我在这里失踪了吗?

这是我的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"
        }
    }
}

2 个答案:

答案 0 :(得分:4)

您可以尝试将gradle(android \ build.gradle)升级到此版本

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

要这样做,您还需要升级android/gradle/wrapper/gradle-wrapper.properties

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

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

这为我解决了类似的问题。

答案 1 :(得分:2)

将您的gradle-wrapper分发网址更改为

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