找不到com.android.tools.build:graddle - 链接返回404

时间:2018-02-16 18:07:33

标签: javascript android reactjs react-native gradle

我试图在朋友的(有点旧的)项目上运行react-native run-android。我收到此错误:

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 :

我尝试输入链接,他们返回404错误。此链接是否放在配置文件中?我在哪里可以获得这些文件的有效链接?要修改哪个文件来获取所述文件?

1 个答案:

答案 0 :(得分:0)

通过在google()文件上将android/app/build.gradle添加到存储库来解决问题。最终结果看起来像

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