srijan pandey
srijan pandey

Reputation: 121

Error in ViewBinding in Kotlin, Error is to check module classpath for missing or conflicting dependancies

enter image description here

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

Answers (8)

Hadi Abedi
Hadi Abedi

Reputation: 166

Just in "Build.gradle(app)" once set viewBinding = false and again set viewBinding = true

Upvotes: 2

dzaralica69
dzaralica69

Reputation: 13

Got the same error while migrating from kotlin synthetics to viewbinding. Cleaning the project fixed it.

Upvotes: 1

Stephen Muindi
Stephen Muindi

Reputation: 81

And also restart Android Studio to invalidate caches. It worked for me.

Upvotes: 0

edaadkyil
edaadkyil

Reputation: 1

Add following in app-level dependency:

android {
    ...
    dataBinding {
        enabled true
    }
}

It worked for me. Good luck...

Upvotes: 0

Sandip Laha
Sandip Laha

Reputation: 61

Add this library in app-level dependency:

implementation 'com.android.databinding:viewbinding:7.2.2'

It worked for me. thanks.

Upvotes: 4

In gradle.properties writing android.enableJetifier = true worked for me.

Upvotes: 4

srijan pandey
srijan pandey

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

Mr.A2
Mr.A2

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

Related Questions