首页 > 解决方案 > 为 android studio 安装 Material Design 时出错

问题描述

在过去的几天里,我一直在熟悉 Android Studio,它在大多数情况下都很稳定,直到我添加了 Material Design 依赖项,并且在构建项目时遇到了一大堆错误。

我一直在修补 buildtools/sdk 版本,但似乎没有任何效果。

这是我的 build.gradle 文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "app.anuythe.com.apend"
        minSdkVersion 24
        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.google.android.material:material:1.1.0'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
}

错误: https ://i.stack.imgur.com/OYWDg.png

标签: androidandroid-studiogradlematerial-design

解决方案


我建议你升级到 AndroidX:

 dependencies {

  implementation 
'com.google.android.material:material:1.1.0'
 implementation 'androidx.appcompat.appcompat:1.1.0'
 implementation 
 'androidx.constraintlayout.constraintlayout:1.1.3'
 }

PS:虽然这些版本不是最新的,但只是为你指明了正确的方向。

干杯!


推荐阅读