The 'kotlin-android-extensions' Gradle plugin is deprecated
As "kotlin-android-extensions" is deprecated now it's better to use view binding.
For this first enable view binding in build.gradle file by writing these line of codes under android block.
buildFeatures {
viewBinding true
}
then in activity file to use view binding features
first declare a global variable for binding as
private lateinit var binding:ActivityMainBinding
Here ActivityMainBinding is a auto generated class
then write these codes in OnCreate() method
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
It's deprecated Base on the google document
Kotlin Android Extensions is deprecated, which means that using Kotlin synthetics for view binding is no longer supported.
for those who's wonder what the synthetic
is. I should say a simple way to access to UI view id with kotlin which was possible by adding 'kotlin-android-extensions'
in Gradle
.
- If your app uses Parcelable you can use
'kotlin-parcelize'
instead of'kotlin-android-extensions'
. - If your app uses Kotlin synthetics for view binding, use this guide to migrate to Jetpack ViewBinding or Data Binding.
It's deprecated now
Remove
'Kotlin-android-extention'
from the plugin. (Used for kotlin's synthetic way to access UI elements)Add below to use
view binding
way to access UI elementandroid { ... buildFeatures { viewBinding true } }
If your app contains
Parcelable
, please add'kotlin-parcelize'
in plugin to use a simple way to create parcelable by just adding@Parcelize
annotation to class
You can see the Google guideline regarding this update.