Kotlin gets the ID automatically error [How to Solve]

Use Android studio to automatically create a kotlin project. To automatically obtain the ID in the layout in the project, you need to follow the steps below

1. In the project build Add ‘kotlin Android extensions’ to gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
}

2. To modify the configuration of sourcecompatibility, the default studio is automatically created using kotlin_version

 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

3. Find gradle.properties file in the root directory of the project, Add android.enableJetifier=true:

android.enableJetifier=true

All right! Then you can use it.
when using it, you need to import the layout file.
normally, press and hold act + enter to select import for automatic import, or you can add it manually. For example, the name of my layout file is activity_main.XML that is import kotlinx android.synthetic.main.activity_main.*

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

Read More: