SL5net
SL5net

Reputation: 2556

Kotlin: Unresolved reference: java

I surprised, because i was able to checkout and run a Kotlin project from Github without this error, and now get get this Java-Error

Unresolved reference: java

I using

i tried hit Alt+Enter. IDE manual says: "Alt+Enter: Show intention actions and quick-fixes."

This is my File-Name:

/home/me/IdeaProjects/KeyEvent-Reader-Demo/src/Test.kt

Same Error i found here: https://discuss.kotlinlang.org/t/kotlin-unresolved-reference-java/6734

Upvotes: 3

Views: 19389

Answers (2)

PavelPraulov
PavelPraulov

Reputation: 629

I had the same problem, the @y.bedrov's suggestion helps me.

The issue is that the Classpath is empty (under Project Structure -> Platform Settings -> SDKs -> <choose active SDK> -> Classpath)

To fix this, you can recreate the SDK:

  1. Project Structure -> Platform SDKs -> <choose active SDK> -> "-"
  2. Project Structure -> Platform SDKs -> "+" -> <choose target SDK location>

Upvotes: 10

chujudzvin
chujudzvin

Reputation: 1303

This was definitely some IntelliJ peoblem for me. I could solve the issue by stupidly deleting the "problematic" class and creating it again:

  • Delete class and imports that refer to it in project
  • Create the same class and adding imports

What generally people also suggest when having similar problem (but didn't help in my case):

  • Restart IDE (File -> Invalidate caches... )
  • Check Platform SDKs as mentioned in another answer here
  • IntelliJ -> PReferances -> Build, Execution, Deployment -> Make sure that Kotlin Compiler and Java Compiler match in versions.

Upvotes: 2

Related Questions