3

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

Giorgio
  • 1,973
  • 4
  • 36
  • 51
srijan pandey
  • 71
  • 1
  • 6
  • can you share your build.gradle file class. – Rudra Rokaya Feb 16 '22 at 09:53
  • And please follow this link https://stackoverflow.com/questions/61775091/android-studio-is-giving-errors-and-warnings-after-enabling-view-binding-how-to this may help. – Rudra Rokaya Feb 16 '22 at 09:54
  • 2
    I encountered this issue in AndroidStudio Chipmunk 2021.2.1 Patch 1. For me the issue got fixed by inValidating the caches, i.e, File > Invalidate Caches > Checked both [(FileSystem & LocalHistory), (VCS log & Indexes)] > Invalidate & restart. – Subind Suresh Aug 06 '22 at 09:09

8 Answers8

4

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

Barney Stinson
  • 212
  • 3
  • 12
4

Add this library in app-level dependency:

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

It worked for me. thanks.

3

it was solved just restarted my laptop and I had an update for one of the dependancies. Thanks alot for the help.

srijan pandey
  • 71
  • 1
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 24 '22 at 13:37
0

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.

Mr.A2
  • 126
  • 4
0

Add following in app-level dependency:

android {
    ...
    dataBinding {
        enabled true
    }
}

It worked for me. Good luck...

edaadkyil
  • 1
  • 1
0

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

0

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

0

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

Hadi Abedi
  • 128
  • 1
  • 5