将 Android Studio 更新到 4.2.1 并将 Build Gradle 版本更新到 4.2.1 后,我在构建项目时遇到问题。gradle-wrapper.properties 中的 gradle 版本是:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
有什么想法可以解决这个问题吗?
错误是:
A problem occurred configuring root project Test.
> Could not resolve all artifacts for configuration :classpath.
> Could not find gradle-4.2.1.jar (com.android.tools.build:gradle:4.2.1).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.2.1/gradle-4.2.1.jar
> Could not find builder-4.2.1.jar (com.android.tools.build:builder:4.2.1).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/4.2.1/builder-4.2.1.jar
> Could not find bundletool-1.1.0.jar (com.android.tools.build:bundletool:1.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/1.1.0/bundletool-1.1.0.jar
> Could not find protos-27.2.1.jar (com.android.tools.analytics-library:protos:27.2.1).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/protos/27.2.1/protos-27.2.1.jar
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
-----------------------------------------------------------------------------------------
// project/build.gradle
buildscript {
ext.kotlin_version = 1.5.0
repositories {
google()
mavenCentral()
}
dependencies {
classpath com.android.tools.build:gradle:4.2.1
classpath org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}