我刚刚把Gradle从3.0.1迁移到了4.4。现在Android Studio显示Gradle构建失败,下面显示以下错误。
由于org.gradle.internal.resolve.ModuleVersionNotFoundException:无法找到com.android.tools.build:gradle:4.4。 搜索以下位置: https://jcenter.bintray.com/com/android/tools/build/gradle/4.4/gradle-4.4.pom https://jcenter.bintray.com/com/android/tools/build/gradle/4.4/gradle-4.4.jar https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.4/gradle-4.4.pom https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.4/gradle-4.4.jar
项目级别的build.gradle文件如下所示
buildscript {
repositories {
jcenter()
google()
}
dependencies {
//classpath 'com.android.tools.build:gradle:3.0.1'
//replaced by 4.4 below
classpath 'com.android.tools.build:gradle:4.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
项目结构如下所示。
4.1.0
,而不是3.1.x
,distributionUrl
应该更新到6.8.x
。 - Brian Li