Kotlin unresolved reference in IntelliJ
UPDATE - 01/2022
The jetbrains thread regarding this issue has moved and is nowhere to be found, so the link below is not valid anymore.
The option, per module, Kotlin -> FIX
does not exist anymore and has been that way for years now since this was a temporary patch to deal with integration issues during the early previous releases.
If anyone stumbles across this and NEITHER Invalidate Cache
or Update Kotlin's Version
work:
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
.
- 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
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).
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'