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:
- Android studio New kotlin project Error: org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21-release-315
- Kotlin: How to Solve kapt import error
- ktor org.jetbrains:kotlin-css-jvm Dependency Failure [Solved]
- How to Solve Kotlin unresolved reference error
- [Solved] Android Kotlin Package release Error: Lint found fatal errors while assembling a release target.
- Runtime error prompt in Android Studio: arrayadapter requires the resource ID to be a textview problem
- Eclipse Graphical Layout Error: Failed to find the style corresponding to the id 2130772027
- How to Solve Gradle Error: Plugin with id ‘jetty’ not found.
- DevC++ Error: [Error] Id returned 1 exit status [How to Solve]
- .NETproject compilation error. Type or namespace name could not be found. Visual studio automatically introduces dependency package (shortcut key)
- Plink Error: Multiple instances of ‘_’ in sample ID.?
- [Solved] Error response from daemon: OCI runtime create failed: container with id exists: xxzxxxxxxxx
- Kafka Error while fetching metadata with correlation id 1 : {alarmHis=LEADER_NOT_AVAILABLE}
- Laravel model save if the table has no ID field Error [How to Solve]
- E11000 duplicate key error collection: *** index: _id_ dup key
- [Solved] OpenCV VideoWriter Error: FFMPEG: tag ‘MP4V‘ is not supported with codec id 12 and format mp4
- Driver error 11: System 0.500000: CAN 1 : Message with ID = 630 could not be sent. Driver error 11 in TransmitCANFrame
- [Solved] Redisson distributed lock error: attempt to unlock lock, not locked by current thread by node id
- [Solved] CCS compilation and debug error: Source lookup: unable to restore CPU specific source container – expecting valid source container id value.
- DataTables warning encountered using DataTables: table id = DataTables_Table_0 – Ajax error. For more information ab