简体   繁体   中英

How to enable viewBinging in android project using Kotlin gradle dsl?

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.

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

just add this block

 viewBinding {
    android.buildFeatures.viewBinding = true
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM