V7 的清单合并失败

Manifest merger failed for V7

我更新了一些东西,突然发生了这种情况

ERROR: Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:7:5-57:19 to override.

我已经查看了其他答案,但我真的不知道该做什么或要改变什么

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
    applicationId "com.example.khali.nutriplan"
    minSdkVersion 22
    targetSdkVersion 28
    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(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
implementation 'com.numetriclabz.numandroidcharts:numandroidcharts:1.0.18'
implementation 'com.xeoh.android:checkboxgroup:1.0.1'
implementation 'com.jjoe64:graphview:4.2.2'
implementation 'androidx.fragment:fragment:1.0.0'
}

什么是合适的库

你正在使用同时支持库和androix库,你不能这样做。

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'androidx.fragment:fragment:1.0.0'

您必须迁移到 Androidx

  • com.android.tools.build:gradle 升级到 v3.2.1 或更高版本。
  • compileSdkVersion 升级到 28 或更高版本。
  • 更新您的应用以使用 Jetpack (AndroidX);按照 Migrating to AndroidX.
  • 中的说明进行操作

如这里所述

https://github.com/material-components/material-components-android/issues/193#issuecomment-486932223

gradle.properties 文件添加两行:

android.useAndroidX=true
android.enableJetifier=true