程序类型已经存在-Material Design Component库和AndroidX

时间:2018-08-24 13:48:10

标签: android gradle kotlin androidx mdc-components

我正在编写一个新的应用程序,并且正在使用AndroidX,因为这似乎是从现在开始最好的方法。

我在尝试将MDCAndroidX组合在一起时遇到了一些麻烦,尽管我没有使用任何旧的支持库依赖项,但是我一直在遇到有关android.support.v4.*名称空间的错误

这是我的软件包级别 build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    ext {
        constraintLayoutVersion = '1.1.2'
        androidxVersion = '1.0.0-rc01'
        drawerlayoutVersion = '1.0.0-alpha1'
        espressoVersion = '3.1.0-alpha1'
        gradleVersion = '3.1.4'
        junitVersion = '4.12'
        kotlinVersion = '1.2.61'
        lifecycleVersion = '2.0.0-rc01'
        navigationVersion = '1.0.0-alpha05'
        roomVersion = '2.0.0-rc01'
        runnerVersion = '1.1.0-alpha1'
    }

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:$gradleVersion"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我的模块级别 build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 28
    dataBinding {
        enabled = true
    }
    defaultConfig {
        applicationId "com.example.goodold.openartmap"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "0.0.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            applicationIdSuffix ".debug"
            debuggable true
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation "androidx.core:core-ktx:$rootProject.androidxVersion" //Support Library
    implementation "androidx.fragment:fragment-ktx:$rootProject.androidxVersion" //KTX Fragments
    implementation "androidx.appcompat:appcompat:$rootProject.androidxVersion"
    implementation "androidx.recyclerview:recyclerview:$rootProject.androidxVersion"
    implementation "com.google.android.material:material:$rootProject.androidxVersion"
    //Material Design Library

    implementation "androidx.room:room-runtime:$rootProject.roomVersion" // Room components
    kapt "androidx.room:room-compiler:$rootProject.roomVersion"

    implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.lifecycleVersion"
    // LiveData + ViewModel
    kapt "androidx.lifecycle:lifecycle-compiler:$rootProject.lifecycleVersion"

    implementation "androidx.drawerlayout:drawerlayout:$rootProject.drawerlayoutVersion"
    implementation "androidx.constraintlayout:constraintlayout:$rootProject.constraintLayoutVersion"

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$rootProject.kotlinVersion"

    testImplementation "junit:junit:$rootProject.junitVersion"
    androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
    androidTestImplementation "androidx.test:runner:$rootProject.runnerVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.espressoVersion"
}

和我的 gradle.properties

org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true

我想念什么?

0 个答案:

没有答案