无法解决:com.google.android.material:material:1.0.0-alpha1

时间:2018-05-05 20:45:49

标签: android gradle

所以我按照官方文档将Material Components库添加到我的项目https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md

但它引发了以下错误 “无法解决:com.google.android.material:material:1.0.0-alpha1”

我已尝试安装Android Studio建议无效的存储库和同步项目。

我的项目配置

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
}

和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'

8 个答案:

答案 0 :(得分:9)

我认为我已经开始分享为我修复这个问题了。

我和你一样有初始设置。为了使它工作,我不得不改变以下内容:

  • compileSdkVersion to 'android-P'
  • 支持图书馆到'28.0.0-alpha1'
  • 在依赖项块中包含api 'com.android.support:design:28.0.0-alpha1'
  • SDK平台更新 - Android P预览(最新)
  • targetSdkVersion 'P'

然后我做了仪式'无效缓存/重新启动'并重建项目以获得良好的衡量标准。

答案 1 :(得分:3)

面向ANDROIDX用户。
您可以执行以下操作...

AndroidX
实施'com.google.android.material:material:1.0.0-alpha3'

旧版本工件用户可以使用以下实现
实现'com.android.support:design:[在此处输入设计库版本]'

*使用不带方括号的版本。
您可以通过以下链接找到设计库版本:https://mvnrepository.com/artifact/com.android.support/design/28.0.0-alpha1

答案 2 :(得分:3)

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'`

答案 3 :(得分:1)

代替:

implementation 'com.google.android.material:material:1.1.0'

使用:

   implementation group: 'com.google.android.material', name: 'material', version: '1.1.0-alpha05'

它有效。

答案 4 :(得分:1)

确保您的gradle.properties使用以下行启用了AndroidX:

android.useAndroidX = true

如果未添加,请添加此行并再次同步项目

Visit For More Details

答案 5 :(得分:0)

对于 androidx 用户: 我的问题得到解决,只需将所有依赖项更新为最新版本即可。只需2分钟即可解决。我的先前版本是1.0.2,并显示相同的错误。我只是单击了出现在错误下方的“ 在项目结构对话框中显示”。从那里,您将获得将依赖关系更新到最新版本的选项。对于除androidx以外的用户来说,相同的效果也可以使用。

答案 6 :(得分:0)

嗯,一小时前发生在我身上...... 我总是建议检查最基本的问题,例如:

转到>> gradle module.app

implementation 'com.google.andorid.material:material:1.2.1' // andorid? me silly 

当你有语法错误时; “无法解析:com.google.android.material:material:x.x.x”出现

祝您有美好的一天!

答案 7 :(得分:-2)

这是我的应用程序gradle设置,对我有用..

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.techmadmax.nodemcu.nodemcuautomation"
        minSdkVersion 21
        targetSdkVersion 28
        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:28.0.0-alpha3'
    implementation 'com.android.support:design:28.0.0-alpha3'
    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'
    compile 'com.github.warkiz.widget:indicatorseekbar:1.2.9'
}