findviewbyid-to-viewbinding
Installation
SKILL.md
Migrating findViewById to ViewBinding
Instructions
findViewById returns View (pre-API 26 it was unchecked) and relies on string-like IDs resolved at runtime. Every rename, deletion, or typo becomes an NPE or ClassCastException. ViewBinding replaces this with a generated, null-safe class per layout.
1. Enable ViewBinding
app/build.gradle:
android {
buildFeatures {
viewBinding true
}
}
Do not enable DataBinding yet — it has a different migration surface and a heavier annotation processor.