找不到com.android.tools.build:gradle:4.6

时间:2018-12-20 23:53:23

标签: android react-native android-gradle build.gradle react-native-android

我正在尝试运行React Native项目,但出现以下错误:

enter image description here

我在网上搜索,但没有成功。

这是我的 build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: "com.github.ben-manes.versions"

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

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

这是我的 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.6-all.zip

感谢任何帮助

1 个答案:

答案 0 :(得分:2)

没有com.android.tools.build:gradle:4.6。 4.6是Gradle版本。 Android Gradle插件版本遵循Android Studio版本。因此,最新生产的Android Gradle插件为com.android.tools.build:gradle:3.2.1

因此,更改:

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

收件人:

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