Search code examples
androidandroid-studiokotlingradleandroid-viewbinding

Android studio kotlin viewBinding caching problems class name


I renamed a class, then gradled the ability to enable viewBinding.

When I import the class, it doesn't find the renamed class, but the one with the old class name.

Can you give me a hand?

buildFeatures {
    viewBinding true
}

Solution

  • Binding class name are decided from your layout file name not your class name so doesn't matter what is or what was your activity or fragment name . It will always use layout file name . Let's say i have created result_profile.xml file then binding class name will be ResultProfileBinding now it doesn't matter whatever class i create or rename

    For more information , checkout this link https://developer.android.com/topic/libraries/view-binding