Cannot access '' which is a supertype of

I’ve been using Kotlin at work for several months now and today I tried creating a new personal project on my machine at home.

I did what I wanted to do in around an hour and spent the rest of the evening pulling my hair trying to figure out gradle and how it relates to Kotlin, IDEA and so on.

The main issue I have can be seen below:

The project compiles fine and tests run successfully, however the IDE keeps complaining about missing stuff. I’ve tried adding all sort of dependencies to the gradle build file (including ones from a project that works) but nothing fixed it. I deleted everything in the project (except src), reimported it back and ended up with the same problem.

On a somewhat unrelated subject, while I like Kotlin as a language (it’s easy, obvious and predictable), gradle is exactly the opposite. The gradle DSL is horrible, unintuitive and inconsistent. On top of that, the Kotlin-Gradle DSL from “Using Gradle” page didn’t work:

I’m sure there are some missing things (maybe imports or smth?), but the docs do not cover anything else. Just sayin’

Not sure about the issue from the first picture, but the in your gradle file the implementation(...) calls need to be inside of a dependencies block.
The first dependency block (within buildscript) is responsible for informing gradle about plugins and stuff used within the build.
Then you need a separate one (outside of buildscript) for the dependencies of your project.

As for gradle… it’s a mess. It’s super hard to use and mostly seems like magic to me. That said it’s still the best build tool I used so far. The documentation isn’t that great either. Still I can’t find anything wrong in the “using gradle” page you linked. What exactly there didn’t work?

Probably your project structure does not specify the sdk correctly

I got the same error today after Intellij upgraded my bundled kotlin plugin on Mac OS. The problem might not be the same, but the error message was identical.

Turns out before my project was using JDK 11, but after the kotlin plugin upgrade the JDK was upgraded as well to 13. I resolved the issue by dropping the existing JDK 11 with the - button in the Project Structure window and then adding it again using the + button - which selected JDK 13 by default. After that this error went away.

1 Like

I wouldn’t say there is anything specifically wrong, but rather incomplete or misleading.

For example, only now (and thanks to you) did I realise that the first example of “Configuring Dependencies” section puts “implementation” inside “dependencies”.

My argument would be that the article sounds like a quick intro to the topic but then it’s too exhaustive. I ended up spending quite some time trying to find a minimal “hello world”-style build.gradle(.kts) file - made worse with my other issue causing me to doubt when the setup actually works vs just some IDE complaints.

1 Like

In my case, I have three options: JDK 1.8, JDK 12 and Kotlin SDK.

Switching to JDK 12 made it work! Thanks a lot!