10

我正在尝试安装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.zipdistributionUrl 和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')

谁能帮我我在这里想念什么?

这是我的毕业典礼

// 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"
        }
    }
}
4

2 回答 2

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

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

于 2018-05-03T14:27:57.607 回答
2

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

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
于 2018-05-03T10:40:54.990 回答