DSL element ‘android.dataBinding.enabled’ is obsolete 解决方法

从谷歌codelabs上克隆的软件,在Android Studio中构建的时候提示:

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.
Affected Modules: app

原因
DSL元素的android.dataBinding被替换为android.buildFeatures.dataBinding,且将在Android Gradle 7.0中被删除。

解决方法
build.gradle: app中使用

1
2
3
4
buildFeatures{
dataBinding = true
viewBinding = true
}

来代替原有的代码。

评论