Android Studio and Kotlin: Unresolved reference: also

Viewed 11977

also compiles and runs from Android Studio:

val greeted = "World".also { println("Hello $it") }

Yet the editor highlights also and it as errors and don't give any help with intellisense. apply still works and when I go to source I can see the definition of both apply and also. How do I get Android Studio to recognize also?

  • Android Studio 2.3.3
  • kotlin_version = '1.1.3-2'
  • Kotlin plugin 1.1.3-release-Studio2.3-2

I've also had this problem with earlier versions.

3 Answers

I tried everything possible and nothing worked. The only solution for me was to delete .AndroidStudio folder from C:/Users/YourName/. Android Studio resets and everything works as it should.

In my case when i added id 'kotlin-android-extensions' to gradle file (app) and synced, problem is solved.

Related