在Android中实现Material Design时出错

时间:2018-05-14 12:40:10

标签: android material-design

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

我目前正在使用的应用程序是一个简单的测试应用程序,只需一个按钮和一些textview。

t放入gradle文件后出现问题。

继承我的build.gradle(app)文件

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

我有4个错误,

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'

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

2 个答案:

答案 0 :(得分:2)

试试这个

更改 compileSdkVersion 和支持库版本

compileSdkVersion  'android-P'
Support Libraries to '28.0.0-alpha1'

并使用

 api 'com.android.support:design:28.0.0-alpha1'

修改

  

更新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()
}

希望这有帮助

答案 1 :(得分:1)

import os import csv for root, dirnames, filenames in os.walk(path): for filename in filenames: if filename.endswith('.txt'): txt_file = ('*.txt') csv_file = ('*.csv') in_txt = csv.reader(open(filename, "rb"), delimiter = '\t') out_csv = csv.writer(open('*.csv', 'wb')) out_csv.writerows(filename) 设为compileSdkVersion

将支持库与'android-P'匹配。例如,compileSdkVersion而不是implementation 'com.android.support:support-v4:28.0.0-alpha1'

implementation 'com.android.support:appcompat-v7:27.1.1'替换为implementation 'com.google.android.material:material:1.0.0-alpha1'

应用api 'com.android.support:design:28.0.0-alpha1'看起来应该是这样的。

build.gradle

正在使用apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 'android-P' defaultConfig { applicationId "com.wolfrevokcats.myapp" minSdkVersion 15 targetSdkVersion 27 versionCode 16 versionName "2.3" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { debuggable false minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { debuggable false minifyEnabled false shrinkResources false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" api 'com.android.support:design:28.0.0-alpha1' implementation 'com.android.support:support-v4:28.0.0-alpha1' implementation ('com.someone.addons:library:1.6.1@aar'){ exclude group: 'com.android.support' exclude module: 'appcompat-v7' exclude module: 'support-v4' } implementation 'com.google.android.gms:play-services-location:15.0.1' 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' } 时,我们的代码必须更改为'com.android.support:design:28.0.0-alpha1'而不是android.support.design个库。以下是使用新的Bottom App Bar小部件的示例。

com.google.android.material