android - 无法在 Gradle 中编译新的 Material 库

标签 android android-gradle-plugin material-design

我无法添加新的 Material Design 库。 当我添加 compile 'com.google.android.material:material:1.0.0-alpha1' 并同步项目时,出现以下两个错误:

error: resource android:attr/fontVariationSettings not found.
error: resource android:attr/ttcindex not found.

我的build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "rockthesport.com.pruebasmaterial"
        minSdkVersion 19
        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.constraint:constraint-layout:1.1.0'
    compile 'com.google.android.material:material:1.0.0-alpha1'
    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'
}

有什么建议吗?

谢谢!

最佳答案

使用新的 Material Components library 'com.google.android.material:material:1.0.0-alpha1' 你必须使用

android {
        compileSdkVersion 'android-P'

        defaultConfig {
            targetSdkVersion 'P'
        }
        ...
    }

关于android - 无法在 Gradle 中编译新的 Material 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50344388/

相关文章:

android - Gradle 升级 - 创建 apk 时缺少 base.apk 代码

android - 如何在android studio中使用maven

android - 从自定义 View 调用 Activity 方法

java - 有时与 Android 的 JDBC 连接不起作用

android - 可以将动画图像加载到 android imagebutton 中吗?

javascript - 如何在 WebView 中扩展 JavaScript 控制台(以匹配 ConsoleMessage.MessageLevel)

android - 将源文件添加到 Gradle 项目

android - 当图像折叠时,NestedScrollView 内的 RecyclerView 不会向上滚动

ios - Material 设计 snackbar 在 swift 4 中不起作用

flutter - 如何在 Flutter 中使用 Material 3 表面色调?