Search code examples
androidgradle-kotlin-dslandroid-viewbinding

How to set ViewBinding in buildgradle.kts?


I could easily set dataBinding in buld.gradle.kts by doing:

dataBinding {
    isEnabled = true
}

But I could not seem to find the equivalent for viewBinding.


Solution

  • As viewBinding.isEnabled is going to be deprecated, using buildFeatures would be better.

    android {
    ...
        buildFeatures {
            viewBinding = true
        }
    }