android.support.design.widget class not found

Viewed 3335

I'm encountering this error in Android Studio:

The following classes could not be found:

- android.support.design.widget.FloatingActionButton (Fix Build Path, Edit XML, Create Class) - android.support.design.widget.TextInputLayout (Fix Build Path, Edit XML, Create Class)

Here are the dependencies of my build.gradle file:

dependencies {
        compile 'com.firebaseui:firebase-ui:0.6.0'
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.appcompat:appcompat:1.0.2'
        implementation 'com.google.firebase:firebase-core:17.0.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        implementation 'com.google.firebase:firebase-messaging:17.3.4'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.2.0'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
        implementation 'com.google.android.gms:play-services-location:16.0.0'
        implementation 'com.google.firebase:firebase-auth:18.0.0'
        implementation 'com.google.android.material:material:1.0.0'
        implementation 'com.google.firebase:firebase-database:18.0.0'
        implementation 'com.android.support:design:27.1.1'
    }

I've tried adding com.android.support:design into the gradle file but it still doesn't solve my problem

4 Answers

Try this:

com.google.android.material:material:1.0.0-rc01

instead

com.android.support:design

I can see you are using AndroidX artifacts. If you are using AndroidX, the other dependencies should be AndroidX as well!

Pre-AndroidX:

com.android.support:design

AndroidX:

com.google.android.material:material:1.0.0-rc01

You can also check out here to see the AndroidX equivalent of the previous artifacts

In addition to the answer from @Amirhosein Heydari, don't forget to add com.google.android.material.floatingactionbutton.FloatingActionButton in your XML.

I invalidated cache/restarted and it worked. Go to file > Invalidate cache/restart

Related