我已经在该网站上尝试了许多解决方案,但是仍然无法解决问题。该问题归因于Android X库。当我添加Android X时,此问题已解决,但打开了新问题。如何解决这个问题?
较早出现此错误:
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 <application> element at AndroidManifest.xml:19:5-142:19 to override.
添加完后tools:replace="android:appComponentFactory"
,出现此错误:
java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs
at com.android.builder.core.AndroidBuilder.mergeManifestsForApplication(AndroidBuilder.java:540)
at com.android.build.gradle.tasks.MergeManifests.doFullTaskAction(MergeManifests.java:173)
合并错误(在Android清单中):
错误:在属性:android:appComponentFactory的第2行指定了tools:replace,但未在应用主清单(此文件)的第1行中指定新值
表现:
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.example"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:replace="allowBackup, android:appComponentFactory"
android:allowBackup="false">
...
<application
android:name="com.example"
android:icon="@mipmap/icon"
android:debuggable="true"
android:hardwareAccelerated="false"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:allowBackup="false"
tools:ignore="GoogleAppIndexingWarning,HardcodedDebugMode">
...