Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin unresolved reference in IntelliJ

People also ask

What is the latest kotlin version?

Kotlin 1.6 was released in November 2021. Kotlin 1.7 was released in June 2022, including the alpha version of the new Kotlin K2 compiler.


Your Intellij IDEA plugin and the Kotlin runtime/compiler that you use in the project need to match. For example if IDE plugin is Beta 1, but your Gradle/Maven project using M12, you'll have issues exactly as you described. So check that everything lines up.

If you still have issues, with some older plugins you need to clear the caches in Intellij IDEA (file menu, Clear Caches and Restart, select option to restart).


If anyone stumbles across this and NEITHER Invalidate Cache or Update Kotlin's Version work:

1) First, make sure you can build it from outside the IDE. If you're using gradle, for instance:

gradle clean build

If everything goes well , then your environment is all good to work with Kotlin.

2) To fix the IDE build, try the following:

Project Structure -> {Select Module} -> Kotlin -> FIX

As suggested by a JetBrain's member here: https://discuss.kotlinlang.org/t/intellij-kotlin-project-screw-up/597


In my case, it was a misconfigured IntelliJ instance.

Project Structure -> SDKs -> Remove and add the Java SDK again


Ran into this issue. I had to add the following to my build.grade:

apply plugin: 'kotlin-android'