Home » Android » import kotlinx.android.synthetic.main.activity_main is not working

import kotlinx.android.synthetic.main.activity_main is not working

Posted by: admin June 15, 2020 Leave a comment

Questions:

Import kotlinx greyed out

enter image description here

I think i try nearly everything. Reinstall Android Studio, Invalide Cache, new Project same Problem.

i just can’t find the Solution

How to&Answers:

Can you try

  • File | Invalidate Caches / Restart
  • Deleting .idea folder
  • Clean
  • Re-import the project

OR just remove apply plugin: 'kotlin-android-extensions' , sync gradle plugin and then I added it again.

Answer:

module gradle

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

dependencies {
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

project gradle

buildscript{
ext.kotlin_version = '1.3.11'
}
 dependencies {
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

Answer:

Simple friend, you forgot the asterisk.

    import kotlinx.android.synthetic.main.activity_main.*

It just happened to me.