在Android中实施Material Design时出错

Dem*_*218 5 android material-design

我一直在阅读新的材料设计网站,但在实施该网站时遇到了问题。

我当前正在使用的应用程序是一个简单的测试应用程序,仅包含一个按钮和一些文本视图。

放置implementation 'com.google.android.material:material:1.0.0-alpha1'在gradle文件中后,问题就来了。

这是我的build.gradle(app)文件

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.user.firebasemessagingtest"
        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'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.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'

    implementation 'com.google.firebase:firebase-core:15.0.2'
    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.2'
    implementation 'com.google.firebase:firebase-ml-vision:15.0.0'
    implementation 'com.google.android.material:material:1.0.0-alpha1'
}

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

我有4个错误,

error: resource android:attr/dialogCornerRadius not found.
error: resource android:attr/fontVariationSettings not found.
error: resource android:attr/ttcIndex not found.
error: failed linking references.
Run Code Online (Sandbox Code Playgroud)

如文档中所述,我已将maven包含在项目gradle文件中。

Nil*_*hod 2

尝试这个

更改compileSdkVersion和支持库版本

compileSdkVersion  'android-P'
Support Libraries to '28.0.0-alpha1'
Run Code Online (Sandbox Code Playgroud)

并使用

 api 'com.android.support:design:28.0.0-alpha1'
Run Code Online (Sandbox Code Playgroud)

编辑

更新您的 SDK 平台更新 - Android P 预览版(最新)

并且还使targetSdkVersion 'P'

Clean-Re_Build-Run你的项目

编辑2

apply plugin: 'com.android.application'

android {

    compileSdkVersion  'android-P'

    defaultConfig {
        applicationId "com.example.nilesh.testapp"
        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'
        }
    }

    defaultConfig {
        vectorDrawables.useSupportLibrary = true
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
    implementation 'com.android.support:support-v4:28.0.0-alpha1'
    compile 'com.android.support:design:28.0.0-alpha1'
    compile 'com.android.support:cardview-v7:28.0.0-alpha1'

    implementation 'com.android.support.constraint:constraint-layout:1.1.0'

    testImplementation 'junit:junit:4.12'

    implementation 'com.google.android.material:material:1.0.0-alpha1'


    implementation 'com.google.firebase:firebase-core:15.0.2'
    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.2'
    implementation 'com.google.firebase:firebase-ml-vision:15.0.0'

    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
repositories {
    mavenCentral()
}
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助