Reputation: 383
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/master/docs/getting-started.md
But it throws me the following error "Failed to resolve: com.google.android.material:material:1.0.0-alpha1"
I've tried installing the repository and sync project that Android Studio suggest to no avail.
My project config
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and the app config
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "mlluell.eftremp"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.firebase:firebase-database:15.0.1'
implementation 'com.google.firebase:firebase-storage:15.0.2'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.android.material:material:1.0.0-alpha1'
//imatges recyclerview
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
// FirebaseUI for Firebase Realtime Database
implementation 'com.firebaseui:firebase-ui-database:3.3.0'
// FirebaseUI for Firebase Auth
implementation 'com.firebaseui:firebase-ui-auth:3.3.0'
// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:3.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
Upvotes: 27
Views: 69587
Reputation: 488
Well that happened to me an hour ago... I always suggest check the most basic issues for example:
Go to >> Gradle module.app
:
implementation 'com.google.android.material:material:1.2.1'
When you have a syntax's error; Failed to resolve: com.google.android.material:material:x.x.x
appears.
Have a great day!
Upvotes: 4
Reputation: 2426
FOR ANDROIDX USERS:
You can implement as follows:
AndroidX:
implementation 'com.google.android.material:material:1.0.0'
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
Upvotes: 7
Reputation: 391
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
Upvotes: 1
Reputation: 1422
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.
Upvotes: 0
Reputation: 1547
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'`
Upvotes: 5
Reputation: 1813
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.
Upvotes: 36
Reputation: 316
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.
Upvotes: 12