After updating to Androis Studio 4.0 I received a warning that android.viewBinding.enabled
was deprecated and shoud lbe replaces with android.buildFeatures.viewBinding
.
I therefoe changed the appropraiet part of my build.gradle (app)
from:
android {
...
viewBinding {
enable = true
}
...
}
to:
android {
...
buildFeatures {
viewBinding {
enabled true
}
}
...
}
I no longer get the warning, but still get an information box in my build window as follows:
build.gradle: DSL element 'android.viewBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.viewBinding'.
It will be removed in version 5.0 of the Android Gradle plugin.
Is this normal? I knows it's not a warning or an error, but it seems odd to tell me about something that has been fixed - or have I not fixed it correctly (my app still works using viewBinding as expected).
(Note also that when adding the buildFeatures
section to the file, none of the required entires, including buildFeatures
pops up in teh auto-complete prompt.)
Solved it!
Although it was working - i.e. the View bindings were working fine - the correct new syntax appears to be:
android {
...
buildFeatures {
viewBinding true
}
...
}
...still not popping up in the auto-complete, though.
Update: After a few buids and rebuilds I checked again and now buildFeatures
IS popping up in teh auto-complete... Guess I wasn't being patient enough for everything to catch up. Just a bit odd that invalidating the caches didn't fix the auto-complete straight away.