So I\'m following the official documentation to add the Material Components library to my project https://github.com/material-components/material-components-android/blob/mas
FOR ANDROIDX USERS.
You can implement as follows...
AndroidX
implementation 'com.google.android.material:material:1.0.0-alpha3'
Old build artifact users can use the following implementation
implementation 'com.android.support:design:[Enter Design library version here]'
*use that version without square brackets.
you can find design library version via this link : https://mvnrepository.com/artifact/com.android.support/design/28.0.0-alpha1
Thought I'd share what fixed this for me now that I|O has started.
I had about the same initial setup as you. To get it working I had to change the following:
'android-P'
'28.0.0-alpha1'
api 'com.android.support:design:28.0.0-alpha1'
in the dependencies block. 'P'
I then did the ritualistic 'Invalidate Caches / Restart' and rebuilt the project for good measure.
For androidx users: My problem got solved by just updating all the dependencies with latest version. It got solved in just 2 minutes. My previous version was 1.0.2 and showed same error. I just clicked on 'Show in Project Structure dialog' which appeared below the error. From there you will get options to update dependencies to latest version. For users other than androidx might be the same soution works.
Instead of:
implementation 'com.google.android.material:material:1.1.0'
Use:
implementation group: 'com.google.android.material', name: 'material', version: '1.1.0-alpha05'
And it works.
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
androidTestImplementation 'androidx.test:runner:1.2.0'`
Make sure your gradle.properties enabled AndroidX using the following Line:
android.useAndroidX = true
If not added then add this line and sync project again
Visit For More Details