Could not find com.android.tools.build:gradle:3.0.1.

执行react-native run-android报错

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'testProject'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:3.0.1.
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
         https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
     Required by:
         project :

这个错是因为更改了gradle版本后 3.0不再是jcenter.bintray.com提供

解决办法:
在repositories{}内添加google()
它会去更换为https://dl.google.com/ 下载

buildscript {
    repositories {
        google()
        jcenter()
    }
    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 {
        google()
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

你可能感兴趣的:(Could not find com.android.tools.build:gradle:3.0.1.)