首页 > 解决方案 > 清单合并失败。该怎么办?

问题描述

试图在模拟器上运行应用程序,但有一个错误,它说:

清单合并失败:来自 [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 的属性 application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) 也存在于[androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory)。建议:将 'tools:replace="android:appComponentFactory"' 添加到 AndroidManifest.xml:6:5-24:19 的元素以覆盖。

我看过很多同样的问题,但没有找到我的问题的答案。

我的 AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.cubehelppp">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:replace="allowBackup, label">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

我从合并清单中得到了这些错误:

Merging Errors: 
Error: Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from AndroidManifest.xml:22:18-86 is also present at AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:6:5-24:19 to override. app main manifest (this file), line 21 

该怎么办?(帖子更新到一个新问题)

标签: javaandroidandroid-studio

解决方案


You can try migrating your project to AndroidX. To migrate, Refactor > Migrate to AndroidX


推荐阅读