构建项目时收到以下警告
DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'.
我在用Android Studio Canary 6
Android Studio Canary 6
从Android Gradle Plugin 4.0.0-alpha05那里开始,有一个名为buildFeatures启用构建功能的新块。
Android Gradle Plugin 4.0.0-alpha05
buildFeatures
因此,为了使用新的 AGP 插件启用数据绑定,您必须在模块(例如:应用程序)级别的 gradle 文件中执行以下操作
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 } }
参考:https ://developer.android.com/studio/releases/gradle- plugin#buildFeatures