Intellij Idea Gradle同步失败:无法获取https://jcenter.bintray.com

pwuypxnk  于 2023-01-25  发布在  其他
关注(0)|答案(1)|浏览(291)

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

整个构建日志是:

Starting Gradle Daemon...
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.
         > 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

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s
ni65a41a

ni65a41a1#

您可以将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从存储库接收到错误(如您的情况),它将抛出异常,抱怨该错误并使构建崩溃。

相关问题