如何解决找不到 gradle-4.2.1.jar (com.android.tools.build:gradle:4.2.1)
在将 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
}
解决方法
从此更改您的构建脚本
repositories {
google()
mavenCentral()
}
进入这个
repositories {
google()
jcenter()
mavenCentral()
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。