0

android { ...I'm trying to enalbe ViewBinding in my project witch use Kotlin Gradle DSL. All examples show how to do it with Groovy DSL.

android {
    ...
    viewBinding {
        enabled = true
    }
}

But this solution isn't works with Kotlin DSL. I was trying solution like this:

android {
    ...
    viewBinding.enabled = true
}

But it also doesn't work. It's interesting, that this approach works for DataBinding.

Atif AbbAsi
  • 5,633
  • 7
  • 26
  • 47

2 Answers2

1

Just an updated way of doing same thing, since isEnabled is deprecated.

just add this block

 viewBinding {
    android.buildFeatures.viewBinding = true
}
vikas kumar
  • 10,447
  • 2
  • 46
  • 52
0

This happens because of old android gradle plugin version. After updating up to 3.6.2 version the problem was solved.