Reputation: 121
I am getting this error in Kotlin, even when I have set viewBinding true in gradle file of app, Please help Cannot access 'androidx.viewbinding.ViewBinding' which is a supertype of 'com.example.cpapp.databinding.ActivityMainBinding'. Check your module classpath for missing or conflicting dependancies
Upvotes: 5
Views: 8250
Reputation: 166
Just in "Build.gradle(app)" once set viewBinding = false and again set viewBinding = true
Upvotes: 2
Reputation: 13
Got the same error while migrating from kotlin synthetics to viewbinding. Cleaning the project fixed it.
Upvotes: 1
Reputation: 81
And also restart Android Studio to invalidate caches. It worked for me.
Upvotes: 0
Reputation: 1
Add following in app-level dependency:
android {
...
dataBinding {
enabled true
}
}
It worked for me. Good luck...
Upvotes: 0
Reputation: 61
Add this library in app-level dependency:
implementation 'com.android.databinding:viewbinding:7.2.2'
It worked for me. thanks.
Upvotes: 4
Reputation: 212
In gradle.properties writing android.enableJetifier = true
worked for me.
Upvotes: 4
Reputation: 121
it was solved just restarted my laptop and I had an update for one of the dependancies. Thanks alot for the help.
Upvotes: 4
Reputation: 126
if you are using Android Studio 3.6.
android {
viewBinding {
enabled = true
}}
or if you are using Android Studio 4.0, viewBinding has been moved into buildFeatures
android {
buildFeatures {
viewBinding = true
}}
after that try to rebuild your project so that the binding class can be generated
then it should work properly
some times android studio gets crazy with bindings so try to invalidate cache and restart too.
Upvotes: 0