我正在使用Android Studio 3.0.1,并且已经将Gradle插件从4.1更新到4.4,并且还尝试将Android插件Gradle从3.0.1升级到3.1.3。问题是AS无法更新android插件,并给了我这个错误。
Error:Could not find com.android.tools.build:gradle:3.1.3.
Searched in the following locations:
file:/F:/android studio/gradle/m2repository/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom
file:/F:/android studio/gradle/m2repository/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.jar
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.jar
https://maven.google.com/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom
https://maven.google.com/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.jar
基于相同的问题,除了在AS 3.0及更高版本中使用的google()之外,我还在Project级别build.gradle中添加了maven repo,但该问题尚未解决。
buildscript {
repositories {
google()
maven {
url "https://maven.google.com"
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven {
url "https://maven.google.com"
}
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
答案 0 :(得分:0)
尝试更改并验证“ gradle-wrapper.properties”文件中的内容,以将gradle dist修改为更高版本,例如
distributionUrl = https://services.gradle.org/distributions/gradle-4.4-all.zip
,还将android support lib版本也更新为最新版本,例如27.1.1
答案 1 :(得分:-1)
确保已选中“启用嵌入式Maven存储库”(在“首选项” /“设置”菜单中)