Lottie 的清单合并问题

Manifest Merge issues with Lottie

当我遇到这个错误时,我正在开始使用 Lottie。我将依赖项添加到 build.gradle

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'org.jsoup:jsoup:1.11.2'
implementation 'com.airbnb.android:lottie:2.8.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha06'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha06'
implementation 'com.android.support:design: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.airbnb.android:lottie:2.8.0' 构建成功但我无法 运行 我的应用程序,因为清单合并中存在错误。

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:14:5-35:19 to override. app main manifest (this file), line 21 

这是我的 Manifest.xml:

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

    <dist:module dist:instant="true" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:logo="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="GoogleAppIndexingWarning">
        <activity android:name=".QuestionActivity"
            android:label="MCQs"/>
        <activity android:name=".TopicActivity"
            android:label="Select Topic"/>
        <activity android:name=".SubjectActivity"
            android:label="Select Subject"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

错误 androidx.core.app.CoreComponentFactory 表明正在使用新的 "Jetpack" 支持库包。看到您的清单使用 "older" 包表明它可能被 lottie 使用。
你可以通过检查库来确定是不是这个原因。
要解决此问题,您可以使用较旧的 lottie 库,开始使用 jetpack 支持库包或手动解决合并问题。如果您导航到 AndroidManifest.xml 并切换到 window.

底部的 Merged Manifest 选项卡,您可以查看合并的清单

建议:

'tools:replace="android:appComponentFactory"' 添加到 <application> 元素 AndroidManifest.xml:14:5-35:19 到 override.app 主清单(此文件),第 21 行