簡體   English   中英

Kotlin 使用 gradle Intellij 構建未使用新控制台應用程序項目構建

[英]Kotlin build not building with fresh console application project using gradle Intellij

我已經使用 Intellij Idea 向導創建了我的簡單項目,該向導設置為創建 Kotlin 控制台應用程序,但似乎 Gradle 同步不起作用(甚至沒有構建項目)。 我嘗試了許多在互聯網上找到的解決方案。

  • 重新安裝 Kotlin 插件
  • 我試圖手動聲明 gradle 插件
  • 甚至重新安裝 Intellij Idea
  • 我嘗試了所有可能的 Intellij 模板,用於 Gradle 和 Kotlin,有或沒有控制台應用程序等。
  • 甚至嘗試使用 java 項目,他們的項目構建,但我無法導入 java.utils.* 甚至 Z93F725A07423FE1C889F448B33D21F46 之類的任何東西。 println() 仍然不起作用。
  • 還有更多,但每次都會出現某種錯誤,我獨立搜索而沒有結果。

我與 Android 工作室和 android 開發合作。 他們有可能在他們之間搞亂配置嗎? 在 Android Studio 上,我在工作和配置 Android Kotlin 項目方面沒有問題。

我可以就下一步做什么尋求一些建議嗎? 我敢肯定,我錯過了一些荒謬的東西。 或者你能給我一些 Gradle Kotlin 的模板代碼嗎?

我真的很想開始寫項目代碼。

非常感謝您提前:)

這是構建錯誤:

A problem occurred configuring root project 'MyProject'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.4.20.
     Required by:
         project :
      > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.4.20.
         > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib/1.4.20/kotlin-stdlib-1.4.20.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib/1.4.20/kotlin-stdlib-1.4.20.pom'.
               > java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
   > Could not resolve org.jetbrains.kotlin:kotlin-reflect:1.4.20.
     Required by:
         project :
      > Could not resolve org.jetbrains.kotlin:kotlin-reflect:1.4.20.
         > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-reflect/1.4.20/kotlin-reflect-1.4.20.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-reflect/1.4.20/kotlin-reflect-1.4.20.pom'.
               > java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-common:1.4.20.
     Required by:
         project :
      > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-common:1.4.20.
         > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.20/kotlin-stdlib-common-1.4.20.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.20/kotlin-stdlib-common-1.4.20.pom'.
               > java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.4.20.
     Required by:
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin-model:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-util-klib:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-util-klib:1.5.0 > org.jetbrains.kotlin:kotlin-util-io:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.5.0 > org.jetbrains.kotlin:kotlin-scripting-common:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.5.0 > org.jetbrains.kotlin:kotlin-scripting-jvm:1.5.0
      > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.4.20.
         > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib/1.4.20/kotlin-stdlib-1.4.20.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib/1.4.20/kotlin-stdlib-1.4.20.pom'.
               > java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
   > Could not resolve org.jetbrains.kotlin:kotlin-reflect:1.4.20.
     Required by:
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.0
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-compiler-runner:1.5.0 > org.jetbrains.kotlin:kotlin-daemon-client:1.5.0
      > Could not resolve org.jetbrains.kotlin:kotlin-reflect:1.4.20.
         > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-reflect/1.4.20/kotlin-reflect-1.4.20.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-reflect/1.4.20/kotlin-reflect-1.4.20.pom'.
               > java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.4.20.
     Required by:
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-compiler-runner:1.5.0 > org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8
      > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.4.20.
         > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib/1.4.20/kotlin-stdlib-1.4.20.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib/1.4.20/kotlin-stdlib-1.4.20.pom'.
               > java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-common:1.4.20.
     Required by:
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.5.0 > org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0 > org.jetbrains.kotlin:kotlin-compiler-runner:1.5.0 > org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8
      > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-common:1.4.20.
         > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.20/kotlin-stdlib-common-1.4.20.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.20/kotlin-stdlib-common-1.4.20.pom'.
               > java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

* Run with --scan

> * Where:
> Auto-applied by using --scan
> What went wrong:
>Plugin [id: 'com.gradle.enterprise', version: '3.5', artifact: 'com.gradle:gradle-enterprise-gradle-plugin:3.5'] was >not found in any of the following sources:
>- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
>- Plugin Repositories (could not resolve plugin artifact 'com.gradle:gradle-enterprise-gradle-plugin:3.5')
>  Searched in the following repositories:
>    Gradle Central Plugin Repository

在此處輸入圖像描述

編輯:看我已經損壞了項目樹。 我嘗試再次創建項目,但在項目文件樹視圖中再次看到一些奇怪的東西在此處輸入圖像描述

編輯 2:正如您在編輯 1 中看到的那樣:有些東西真的很奇怪。 為此,我添加了另一張圖片,其中展示了另一個有類似問題的項目(我做了大概 10 個,而且我總是遇到一些類似的問題)。 我感到很困惑:/ 在此處輸入圖像描述 編輯 3:

我嘗試使用不同的 JDK - 我將其更改為 Adobe Open Jdk,問題就解決了。 謝謝:) 在此處輸入圖像描述

解決方案,如果 JDK 已損壞,這對我有用,正如@Ananiya Jemberu 在評論部分所建議的那樣

我嘗試使用不同的 JDK - 我將其更改為 Adobe Open Jdk,問題就解決了。

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM