【问题标题】:Material design and Appcompat-v7 not supported in Android?Android 不支持 Material Design 和 Appcompat-v7?
【发布时间】:2019-11-17 17:58:38
【问题描述】:

我是 Android 编程新手。当我尝试将材料设计库添加到 build.gradle 它在​​实现“com.android.support:appcompat-v7:28.0.0”下显示错误。
错误信息是:

使用groupId com.android.supportandroidx.*的依赖不能合并但是发现IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='support-fragment', myVersion='28.0.0', myPacking='aar', myClassifier='null'}IdeMavenCoordinates{myGroupId='androidx.arch.core', myArtifactId='core-runtime', myVersion='2.0.0', myPacking='aar', myClassifier='null'}不兼容的依赖少... (Ctrl+F1)
检查信息:有一些库或工具和库的组合不兼容,或者可能导致错误。一种这样的不兼容性是使用不是最新版本的 Android 支持库版本(或者特别是低于您的 targetSdkVersion 的版本)进行编译。问题 ID:GradleCompatible

我不想删除 appcompat,因为我想支持较低的版本。

这是我的 gradle 代码:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "com.vignesh.materialdesigntest"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "com.google.android.material:material:1.1.0-alpha07"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    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'
}

【问题讨论】:

  • 迁移到androidx

标签: android android-studio material-design android-appcompat


【解决方案1】:

在 Android Studio 中,导航到Refactor 菜单并选择Migrate to AndroidX

【讨论】:

    【解决方案2】:

    您需要迁移到 AndroidX

    进入安卓工作室菜单

    重构

    在这个菜单下 去

    迁移到 AndroidX

    欲了解更多信息AndroidX

    希望对您有所帮助!

    【讨论】:

    • 那么我们现在必须将最低 Api 级别设置为 26 吗?对旧设备的支持如何?
    猜你喜欢
    • 2015-10-04
    • 2015-01-31
    • 2017-06-20
    • 1970-01-01
    • 1970-01-01
    • 2014-12-30
    • 1970-01-01
    • 2015-02-06
    • 2014-12-31
    相关资源
    最近更新 更多