Andre Thiele
Andre Thiele

Reputation: 4191

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

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

Upvotes: 15

Views: 8669

Answers (3)

user1575326
user1575326

Reputation: 366

The IDE's JDK registrations are most likely inaccurate or outdated. In my case this was in Android Studio and tied to a Toolbox issue. Whatever your case, the principle is the same.

Option 1: Different JDK

Search for the "Gradle" page settings in Preferences, pick or download a different compatible JDK from the list, then run Gradle sync.

If that works, you know the problem. If you can just stick with the new one, great. If you need to fix the previous JDK (e.g. you're in Android Studio and want the embedded one), you will want to rebuild the JDK table.

Option 2: Rebuild JDK Table

  1. Shut down the IDE
  2. Find and delete jdk.table.xml from your app's config directory (somewhere in ~/Library/Application Support/ or %APPDATA%)
  3. Start up the IDE and let it finish indexing.
  4. Return to Gradle preferences and specify your preferred JDK

Upvotes: 10

Kaaveh Mohamedi
Kaaveh Mohamedi

Reputation: 1805

I always had this issue in Android studio, but there is an easy way to solve it:

replace default "Embedded JDK" with a path to the separately downloaded JDK

For example in Android studio: Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JDK

After that, Reload Gradle Project.

Upvotes: 0

Andre Thiele
Andre Thiele

Reputation: 4191

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.

Upvotes: 7

Related Questions