35.2 Enabling Data Binding
The first step in using data binding is to enable it within the Android Studio project. This involves adding a new property to the Module level build.gradle file, so open this file (app -> Gradle Scripts -> build.gradle (Module: app)) as highlighted in Figure 35-1:
Figure 35-1
Within the build.gradle file, add the element shown below to enable data binding within the project:
apply plugin: 'com.android.application'
android {
dataBinding {
enabled = true
}
compileSdkVersion 29
.
.
}
Once the entry has been added, a yellow bar will appear across the top of the editor screen containing a Sync Now link. Click this to resynchronize the project with the new build configuration settings:
Figure 35-2