Gradle Kotlin DSL: "cannot access java.lang.String" error

This is an old bug but I have no idea how to handle it:

Is there any YouTrack issue on that? I am using IntelliJ 2019.3.1, Gradle 6.0.1, JDK 1.8 and 11, Windows 10.

Many other errors IntelliJ/Gradle related are present. The project is this one: https://github.com/lamba92/FirebaseMultiplatform

Does it only happen in the build script? We have https://youtrack.jetbrains.com/issues/KT?q=“Check%20your%20module%20classpath”%20-Resolved%20Subsystems:%20{IDE.%20Gradle}%20, but it doesn’t look the same.

Try to change your project SDK to 8 or remove .idea folder and reimport, and kill all Gradle daemons.

Well, I assure you that I have switched many JDKs and the bug was never solved.
this time I choose GraalVM with JDK8, reboot the computer and it stopped complaining, deleting .idea was not necessary.

I believe that the issue may appear again. If so I’ll update the post!
Thank you tho :slight_smile:

Ran into the same issue when updating from Kotlin 1.3.72 to 1.4.0, this is what worked for me:

  • Checkout the project again from version control, in a different location, and import it, this worked.
  • Re-open the existing project, this time the build.gradle.kts file loaded without any errors.

Also I tried a bunch of things from here, but none of it worked: https://stackoverflow.com/questions/31712046/kotlin-unresolved-reference-in-intellij/34625454

This is probably https://youtrack.jetbrains.com/issue/KT-41141. Please remove all empty JDKs in IDEA “Project structure | SDKs” dialog, this should help.

10 Likes

Same, I solved by closing the project, deleting .idea and re-opening it again from the gradle.build.kts

1 Like

@Alexey.Belkov

Thank you for the suggestion.
Indeed there were some empty JDK-s in the Idea.
But who produced these invalid JDKs?
IMPO there is still an issue in there.
I use the Jetbrains Toolbox for the Jetbrains IDEs installation.
And noticed that (some or all of) the invalid paths of the empty JDKs pointed to subdirectories of the Jetbrains toolbox installation root.
What do you think?
Could it be an issue in there?

Thanks

It’s still a problem of course, we will investigate it in https://youtrack.jetbrains.com/issue/KT-41141

1 Like

Oh my god, thank you so much! I was pulling my hair out over this. This fixed the issue for me.

I also installed through toolbox so I guess I was hit by the same bug.

Deleting .idea fixed this for me

In Android Studio Arctic Fox | 2020.3.1 Canary 2 I have to configure the same SDK and Project language level.
deleting .idea & .gradle folders didn’t work.