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

一、問題

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

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

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>

二、解決方案

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

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

 
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章