简体   繁体   English

Kotlin 使用 gradle Intellij 构建未使用新控制台应用程序项目构建

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

I have created my simple project using Intellij Idea wizard set up to create a Kotlin console Application but seems like Gradle sync is not working (the project is not even builded).我已经使用 Intellij Idea 向导创建了我的简单项目,该向导设置为创建 Kotlin 控制台应用程序,但似乎 Gradle 同步不起作用(甚至没有构建项目)。 I tried many solutions which I found on the internet.我尝试了许多在互联网上找到的解决方案。

  • Reintall Kotlin plugin重新安装 Kotlin 插件
  • I tried to declare the gradle plugin manually我试图手动声明 gradle 插件
  • Even reinstall Intellij Idea甚至重新安装 Intellij Idea
  • I tried all possible Intellij templates, for Gradle and Kotlin, with or without console application and etc.我尝试了所有可能的 Intellij 模板,用于 Gradle 和 Kotlin,有或没有控制台应用程序等。
  • Even tried with the java project, their project builds, but I can't import any stuff like java.utils.* or even from java.甚至尝试使用 java 项目,他们的项目构建,但我无法导入 java.utils.* 甚至 Z93F725A07423FE1C889F448B33D21F46 之类的任何东西。 println() still doesn't work. println() 仍然不起作用。
  • And many more, but every time there is some kind of error, which I search independently without result.还有更多,但每次都会出现某种错误,我独立搜索而没有结果。

I work with Android studio and android development.我与 Android 工作室和 android 开发合作。 Is it possible they to mess configurations between them?他们有可能在他们之间搞乱配置吗? On Android Studio, I don't have problems with working and configuring the Android Kotlin projects.在 Android Studio 上,我在工作和配置 Android Kotlin 项目方面没有问题。

Can I ask for some advice on what to do next?我可以就下一步做什么寻求一些建议吗? I am sure, that I missing something ridiculous.我敢肯定,我错过了一些荒谬的东西。 Or can you give me some template code for Gradle Kotlin?或者你能给我一些 Gradle Kotlin 的模板代码吗?

I really want to start to write project code.我真的很想开始写项目代码。

Thank you very much in advance:)非常感谢您提前:)

Here is the build error:这是构建错误:

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

在此处输入图像描述

EDIT: Look I have corrupted the Project tree.编辑:看我已经损坏了项目树。 I tried to create again project and I again see something strange in the Project file tree view我尝试再次创建项目,但在项目文件树视图中再次看到一些奇怪的东西在此处输入图像描述

EDIT 2: as you see in EDIT 1: something is really strange.编辑 2:正如您在编辑 1 中看到的那样:有些东西真的很奇怪。 For that, I add another picture where I show another project with similar problems ( I made maybe 10, and I always have some kind of similar problems ).为此,我添加了另一张图片,其中展示了另一个有类似问题的项目(我做了大概 10 个,而且我总是遇到一些类似的问题)。 I am so confused:/我感到很困惑:/ 在此处输入图像描述 EDIT 3:编辑 3:

I tried with a different JDK - I changed it to Adobe Open Jdk and the problem was solved.我尝试使用不同的 JDK - 我将其更改为 Adobe Open Jdk,问题就解决了。 Thank you:)谢谢:) 在此处输入图像描述

The solution, Incase the JDK is corrupted, which worked for me as @Ananiya Jemberu suggest in the comment section解决方案,如果 JDK 已损坏,这对我有用,正如@Ananiya Jemberu 在评论部分所建议的那样

I tried with a different JDK - I changed it to Adobe Open Jdk and the problem was solved.我尝试使用不同的 JDK - 我将其更改为 Adobe Open Jdk,问题就解决了。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Gradle构建应用程序构建AOSP项目 - Building AOSP project with gradle build application Intellij Idea日志GradleConnectionException:无法在构建时使用Gradle安装执行构建 - Intellij Idea log GradleConnectionException: Could not execute build using Gradle installation while building 在Kotlin android项目中使用intellij-markdown - using intellij-markdown in kotlin android project 使用Gradle将AndroidSlidingUpPanel添加到IntelliJ IDEA项目 - Add AndroidSlidingUpPanel to IntelliJ IDEA project using Gradle 无法使用 Gradle 在 Kotlin 项目中导入依赖项 - Could not import a dependency in Kotlin project using Gradle 使用不带Android Studio的gradle构建Android multidex应用程序(在构建服务器上) - Building an Android multidex application using gradle without Android Studio (on a build server) 使用 Jenkins 构建 Gradle 项目时出错 - Error in building Gradle project using Jenkins 使用teamcity使用gradle构建android项目时出错 - Error building android project with gradle using teamcity 尝试在IntelliJ上构建Gradle项目时出现错误代码B0 - Error code B0 when trying to build gradle project on IntelliJ 使用 intellij、kotlin 多平台和 gradle 时找不到 Android 平台 - Android platform not found when using intellij, kotlin multiplatform and gradle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM