【问题标题】:Errors installing Material Design for android studio为 android studio 安装 Material Design 时出错
【发布时间】:2020-09-30 01:15:01
【问题描述】:

过去几天我一直在熟悉 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

【问题讨论】:

  • 使用 compileSdkVersion 29 并且不要将 androidx 库与支持库混用

标签: android android-studio gradle material-design


【解决方案1】:

我建议你升级到 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:虽然版本不是最新的,但只是为你指明了正确的方向。

干杯!

【讨论】:

  • 谢谢,看来我错过了文档中关于 androidx 部分的内容非常感谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-11
  • 2017-02-25
相关资源
最近更新 更多