Step #6: Enabling View Binding
We are going to need to start working with our widgets from Kotlin. There are a variety of options for doing this. The one that we will use in this book is called “view binding”. By enabling view binding, the build tools will code-generate a class that helps us work with our widgets in a type-safe fashion.
To turn this on, add these lines to the android
closure in your app/build.gradle
file:
buildFeatures {
viewBinding true
}
When the editor suggests that you sync your Gradle files with the project, go ahead and do that.
NOTE: You will see these lines written elsewhere as:
buildFeatures {
viewBinding = true
}
That was the correct syntax for a while, but Arctic Fox (and its edition of the Android Gradle Plugin) changed the syntax.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.