Gradle同步失败

goucqfw6  于 2023-01-21  发布在  其他
关注(0)|答案(1)|浏览(201)

我根据JetBrains的教程创建了一个Kotlin应用程序。但是我遇到了构建失败的错误。是什么问题?
https://www.jetbrains.com/help/idea/create-your-first-kotlin-app.html?section=Gradle%20Groovy
以下是我的截图:

整个构建日志是:

Gradle Daemon started in 1 s 83 ms

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'hello'.
> Could not resolve all files for configuration ':classpath'.
  > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.21.
    Required by:
        project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21
     > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.21.
        > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.7.21/kotlin-gradle-plugin-api-1.7.21.pom'.
           > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.7.21/kotlin-gradle-plugin-api-1.7.21.pom'. Received status code 403 from server: Forbidden
  > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.21.
    Required by:
        project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21
     > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.21.

正在启动Gradle守护程序... Gradle守护程序在1秒83毫秒内启动
失败:生成失败,出现异常。

  • 出了什么问题:配置根项目"hello"时出现问题。

Could not resolve all files for configuration ':classpath'. Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.7.21/kotlin-gradle-plugin-api-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.7.21/kotlin-gradle-plugin-api-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.7.21/kotlin-gradle-plugin-api-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.7.21/kotlin-gradle-plugin-api-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-gradle-plugin-model/1.7.21/kotlin-gradle-plugin-model-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin-model/1.7.21/kotlin-gradle-plugin-model-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-tooling-core:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-tooling-core:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-tooling-core/1.7.21/kotlin-tooling-core-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-tooling-core/1.7.21/kotlin-tooling-core-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-idea:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-gradle-plugin-idea/1.7.21/kotlin-gradle-plugin-idea-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin-idea/1.7.21/kotlin-gradle-plugin-idea-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-idea-proto:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin-idea-proto:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-gradle-plugin-idea-proto/1.7.21/kotlin-gradle-plugin-idea-proto-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin-idea-proto/1.7.21/kotlin-gradle-plugin-idea-proto-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-util-klib:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-util-klib:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-util-klib/1.7.21/kotlin-util-klib-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-util-klib/1.7.21/kotlin-util-klib-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-klib-commonizer-api:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-klib-commonizer-api/1.7.21/kotlin-klib-commonizer-api-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-klib-commonizer-api/1.7.21/kotlin-klib-commonizer-api-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-project-model:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-project-model:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-project-model/1.7.21/kotlin-project-model-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-project-model/1.7.21/kotlin-project-model-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.7.21/kotlin-compiler-embeddable-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.7.21/kotlin-compiler-embeddable-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-annotation-processing-gradle/1.7.21/kotlin-annotation-processing-gradle-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-annotation-processing-gradle/1.7.21/kotlin-annotation-processing-gradle-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-android-extensions:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-android-extensions:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-android-extensions/1.7.21/kotlin-android-extensions-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-android-extensions/1.7.21/kotlin-android-extensions-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-compiler-runner:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-compiler-runner:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-compiler-runner/1.7.21/kotlin-compiler-runner-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-runner/1.7.21/kotlin-compiler-runner-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.7.21/kotlin-scripting-compiler-embeddable-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.7.21/kotlin-scripting-compiler-embeddable-1.7.21.pom'. Received status code 403 from server: Forbidden Could not resolve org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.21. Required by: project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.21 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21 > Could not resolve org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.7.21. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-scripting-compiler-impl-embeddable/1.7.21/kotlin-scripting-compiler-impl-embeddable-1.7.21.pom'. > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-scripting-compiler-impl-embeddable/1.7.21/kotlin-scripting-compiler-impl-embeddable-1.7.21.pom'. Received status code 403 from server: Forbidden

  • 试试看:

使用--stacktrace选项运行以获得堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。使用--scan运行以获得完整的见解。

构建在7秒内失败

41ik7eoe

41ik7eoe1#

您可以将IntelliJ IDEA更新到最新版本并重新创建项目。您还可以从build.gradlesettings.gradle中删除jcenter()使用。

原因:

你的Gradle日志显示

Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.7.21/kotlin-gradle-plugin-api-1.7.21.pom'. Received status code 403 from server: Forbidden

这意味着它试图从JCenter下载Kotlin。但是,JCenter有stopped their service on May 1st 2021
Kotlin也可以在Maven Central上找到。我们鼓励您使用Maven Central。
新的IntelliJ会默认使用Maven Central生成项目。对于您来说,我猜您使用的是旧的IntelliJ IDEA,或者旧的Kotlin或Gradle插件。

为什么Gradle不能回退到Maven Central?

当您声明多个存储库时,Gradle将逐个尝试。如果一个存储库返回404 Not Found,Gradle将尝试其他存储库,这听起来不错。但如果Gradle从存储库接收到错误(如您的情况),它将抛出异常,抱怨该错误并使构建崩溃。

相关问题