11.4 Enabling View Binding
As of Android Studio 4.0, view binding is not enabled by default. To use view binding, therefore, some changes must be made to the build.gradle file for each module in which view binding is needed. In the case of the AndroidSample project, this will require changes to the Gradle Scripts -> build.gradle (Module: AndroidSample.app) file. To begin with, the viewBinding property must be enabled within the android section of the file:
.
.
android {
buildFeatures {
viewBinding = true
}
.
.
Once these changes have been made, use the Build menu to clean and then rebuild the project to make sure the binding class is generated. The next step is to use the binding class within the code.