DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'

Starting from Android Gradle Plugin 4.0.0-alpha05 there is a new block called buildFeatures to enable build features.

So in order to enable databinding with new AGP plugin you have do like following in module (ex: app) level gradle file

build.gradle ( Groovy DSL )

// shorter version
// android.buildFeatures.dataBinding true


// longer version

android {

    buildFeatures {

         dataBinding true

         // for view binding:
         // viewBinding true
    }
}

build.gradle.kts ( Kotlin DSL )

// shorter version
// android.buildFeatures.dataBinding = true


// longer version

android {

  buildFeatures {

         dataBinding = true

         // for view binding:
         // viewBinding = true
    }
}

Reference: https://developer.android.com/studio/releases/gradle-plugin#buildFeatures


This warning occurs because


    dataBinding {
        enabled=true
    }

    viewBinding {
        enabled=true
    }

This code style is deprecated and it will remove from the gradle version 5 now if you still want to use this then you can use androidx legacy support dependencies

in app lavel build.gradle

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

otherwise you can use new code style to enable data binding and view binding

like this

android {

  buildFeatures {

         dataBinding = true

         // for view binding:
         // viewBinding = true
    }
}

Put it in build.gradle(applevel).It will work with android studio version greater than or equal to 4.0.0.

     android {
             buildFeatures{ 
                    dataBinding = true // for data binding 
                    viewBinding = true // for view binding
              }
     }