Android Studio中Gradle sync failed

时间:2023-03-09 21:36:31
Android Studio中Gradle sync failed

问题:Android Studio中更新同步Gradle 失败

    Gradle sync failed: 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 :
Consult IDE log for more details (Help | Show Log) (2s 787ms)

解决办法: 在工程目录下的build.gradle文件中,添加 google() 这一行。

buildscript {
repositories {
//添加
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1' // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
} allprojects {
repositories {
     //添加
google()
jcenter()
}
} task clean(type: Delete) {
delete rootProject.buildDir
}