Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Gets following warning when building the project

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

I am using Android Studio Canary 6

like image 605
user158 Avatar asked Oct 10 '22 18:10

user158


People also ask

Is data binding deprecated Android?

Kotlin Android Extensions is deprecated, which means that using Kotlin synthetics for view binding is no longer supported.

What is data binding in Android?

The Data Binding Library is a support library that allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically. Layouts are often defined in activities with code that calls UI framework methods.

What happened to the databinding DSL element in Android Studio?

DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'. の解消 Android Studio4.0にバージョンアップしてからコンパイルした際に以下のようなwarningが出ていた。 Copied! DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'.

What happened to databinding in qiita DSL?

DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'. の解消 - Qiita DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'.

What happened to'databinding'in the qiita DSL element?

DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'. の解消 - Qiita DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'. の解消 Android Studio4.0にバージョンアップしてからコンパイルした際に以下のようなwarningが出ていた。 Copied!

What happened to the databinding element in the Android Gradle plugin?

DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'. It will be removed in version 7.0 of the Android Gradle plugin. DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'.


1 Answers

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

like image 379
user158 Avatar answered Oct 13 '22 08:10

user158