简体   繁体   中英

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). I tried many solutions which I found on the internet.

  • Reintall Kotlin plugin
  • I tried to declare the gradle plugin manually
  • Even reinstall Intellij Idea
  • I tried all possible Intellij templates, for Gradle and Kotlin, with or without console application and etc.
  • Even tried with the java project, their project builds, but I can't import any stuff like java.utils.* or even from java. println() still doesn't work.
  • 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. 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.

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?

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. 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 ). I am so confused:/ 在此处输入图像描述 EDIT 3:

I tried with a different JDK - I changed it to Adobe Open Jdk and the problem was solved. Thank you:) 在此处输入图像描述

The solution, Incase the JDK is corrupted, which worked for me as @Ananiya Jemberu suggest in the comment section

I tried with a different JDK - I changed it to Adobe Open Jdk and the problem was solved.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM