Android編譯出現DSL element android.dataBinding.enabled is obsolete and has been replaced with android

1、問題

  編譯的時候發現,發現如下警告,大概意思是android

  DSL元素的android.dataBinding。已被替換爲「android.buildFeatures.dataBinding」,它將在5.0版的Android Gradle插件中被刪除。app

build.gradle: DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'.
It will be removed in version 5.0 of the Android Gradle plugin.
Affected Modules: <a href="openFile:F:/baseDemo/app/build.gradle">app</a>

2、解決方案

 參考:https : //developer.android.com/studio/preview/features#agp-4-0-0,發現從Android Gradle Plugin4.0.0 開始,有一個被稱爲buildFeatures啓用構建功能的模塊,因此要使用新的AGP插件啓用數據綁定,得改成如下配置:gradle

buildFeatures{
        dataBinding = true
        // for view binding :
        // viewBinding = true
    }

相關文章
相關標籤/搜索