简体   繁体   中英

Error after adding buildFeatures in build.gradle file

After i added the buildFeatures { viewBinding = true } setting in my build.gradle file, i got this error:

Gradle sync failed: Could not find method buildFeatures() for arguments [build_7orzo6phc1edx9en9cbbvrw3q$_run_closure1$_closure3@23aed4b2] on object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

I have recently updated my studio to version 4, but the error seems to persist.

Any idea how i can fix this?

enter image description here

I don't know why but the official documentation is wrong It seems that this

buildFeatures {
    viewBinding true
}

Is replaced with

viewBinding {
    enabled true
}

Reference

For build.gradle.kts

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

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