Cannot access 'java.lang.Object' which is a supertype of 'org.gradle.api.artifacts.dsl.DependencyHandler'

Viewed 2564

Why is my build.gradle.kts file looking like this? This is a fresh Spring Boot project generated with start.spring.io. I already tried invalidate caches / restart, rebuild, resyncing and nothing works. Thanks in advance!

enter image description here

2 Answers

This is what solved it:

  1. Delete ~/.gradle/caches
  2. Uninstall and Delete ~/Library/Application\ Support/Library/JetBrains/IntelliJIdea
  3. Delete <project dir>/.gradle
  4. Delete <project dir>/.idea
  5. Start IDEA and reimport the project.

Simpler alternative to try first: Switch your Gradle JDK.

I encountered the same not in a Spring project in IDEA, but in Android Studio. Whatever the case, this was an indirect error message seen as a cascading failure.

Nuking everything like André did will probably work, but it maybe be because deleting the .idea folder and reimporting results in settings/discovering a new JDK (probably the one in JAVA_HOME). Go to your settings, find Gradle, switch JDKs, then resync Gradle.

Related