Archie G. Quiñones
Archie G. Quiñones

Reputation: 13708

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.

Upvotes: 2

Views: 4469

Answers (3)

Hellen
Hellen

Reputation: 76

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

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

Upvotes: 5

EpicPandaForce
EpicPandaForce

Reputation: 81578

android {
  viewBinding {
    isEnabled = true
  }
}

With Android Gradle Plugin 3.6.0 or newer, with Android Studio 3.6.0 or newer, and with Android Build Tools newer than 3.6.0 (classpath("com.android.tools.build:gradle:3.6.0")

Upvotes: 1

Benjamin Ledet
Benjamin Ledet

Reputation: 1033

You need to be on Android Studio 3.6 and add :

android {
  viewBinding.isEnabled = true
}

Update :

You also need your gradle plugin to be at least on 3.6.0

Upvotes: 4

Related Questions