While using data binding , I am not able to get class MainActivityBinding
as per Data Binding Guide
My layout name is activity_main.xml
.
I am also see Android - DataBinding - How and when the Binding classes will be generated? but it can't help me.
Recently Android has announced that with Kotlin 1.4. 20, their Android Kotlin Extensions Gradle plugin will be deprecated and will no longer be shipped in the future Kotlin releases. Android Kotlin Extensions plugin brought with it two very cool features : Synthetics let you replace calls to findViewById with kotlinx.
View binding doesn't support layout variables or layout expressions, so it can't be used to declare dynamic UI content straight from XML layout files. View binding doesn't support two-way data binding.
DataBinding class will be generated based on your xml file name. It is clearly mentioned in doc you are following.
By default, a Binding class will be generated based on the name of the layout file, converting it to Pascal case and suffixing “Binding” to it. The above layout file was main_activity.xml so the generate class was MainActivityBinding
If your xml name is activity_main.xml
than DataBinding class name will be ActivityMainBinding
.
If your xml name is main_activity.xml
than DataBinding class name will be MainActivityBinding
.
Dont forget to clean and build project once
you can follow this tutorial for more about DataBinding
TRY Renaming the xml file to another name and check if binding works once it works rename it back to the one that was used.
That helped for Android Studio 3.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With