Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IDEA reports errors in build.gradle.kts while command line gradle run succeeds

I am using Kotlin DSL with Gradle build tool. My gradle build works well both locally and on jenkins server when run from command line.

However IDEA complains and marks several items red with the following errors:

  • Cannot access class 'java.lang.Object'. Check your module classpath for missing or conflicting dependencies
  • None of the following functions can be called with the arguments supplied

I have tried all 3 options in project settings: - Use default gradle wrapper - Use gradle 'wrapper' task configuration - Use local gradle distribuition

Result if pretty same

QUESTION: is something wrong in config, or is there a fix or workaround for that?

IntelliJ IDEA 2018.1.2 (Community Edition)
Build #IC-181.4668.68, built on April 24, 2018
JRE: 1.8.0_152-release-1136-b29 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-20-generic

.

Kotlin plugin: 1.2.41-release-IJ2018.1-1

.

Gradle 4.7
------------------------------------------------------------

Build time:   2018-04-18 09:09:12 UTC Revision:     b9a962bf70638332300e7f810689cb2febbd4a6c

Groovy:       2.4.12 Ant:          Apache Ant(TM) version 1.9.9 compiled on February 2 2017 JVM:          1.8.0_171 (Oracle Corporation 25.171-b11) OS:           Linux 4.15.0-20-generic amd64

None of the following functions can be called with the arguments supplied

Cannot access class 'java.lang.Object'. Check your module classpath for missing or conflicting dependencies

UPD: @tweitzel you are right, it was incorrect SDK setting, thanks!

like image 456
ludenus Avatar asked Apr 30 '18 13:04

ludenus


People also ask

How do I run a Gradle test from the command line?

Use the command ./gradlew test to run all tests.

How fix Gradle build failed?

You can resolve gradle by going C:\Users\(user name path)\. gradle and delete this . gradle file build again and make sure you are connected to internet.


1 Answers

in my case I had set a jdk as File->Project Structure... -> Project->Project SDK

instead of setting the Kotlin SDK

after setting Kotlin SDK as Project SDK my build.gradle.kts errors disappeared

like image 133
Dirk Hoffmann Avatar answered Oct 21 '22 11:10

Dirk Hoffmann