添加 material 设计支持后清单合并失败并出现多个错误

Manifest merger failed with multiple errors after adding material design support

我的应用程序之前工作正常,但最近在 android 饼图更新后,我将 targetSDKVersion 更改为 28 并添加了 material 设计支持,但出现此错误。

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-53:19 to override.

我已经更新了所有库并尝试了它给我的所有建议,但我仍然无法理解该程序。以下是我添加的依赖项。

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-compat:28.0.0'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'com.android.support:support-annotations: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'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation "com.android.support:support-core-utils:28.0.0"
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation group: 'com.android.support', name: 'customtabs', version: '28.0.0'
}

它说你的 support 依赖项与 androidx.core 依赖项有冲突

android 工作室无法同时使用 android x 依赖项和之前的 support 依赖项。你应该只使用其中之一。

使用这些依赖项

implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'

使用此 link 重构您的依赖项 https://developer.android.com/topic/libraries/support-library/refactor

我的错误已解决,我的假设是为了使用 material 设计,我们需要将 android studio 更新到 3.2,因为在我使用 3.1 并将我的项目迁移到 androidx。并添加这两行

android.useAndroidX=true
android.enableJetifier=true

在项目的gradle.properties文件中,否则你会得到我问题中提到的错误。

我在没有它的情况下尝试过,发现正是因为它我才收到错误。要将依赖项升级到 androidx,请访问此站点 - https://developer.android.com/topic/libraries/support-library/refactor 或者您可以从工作室的折射器选项卡自动执行此操作。