【发布时间】:2019-04-15 13:40:19
【问题描述】:
我在这个网站上尝试了很多解决方案,但问题仍然没有解决。问题是由于 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 清单中):
错误:工具:替换在第 2 行指定的属性 android:appComponentFactory,但没有指定新值 app main 清单(此文件),第 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">
...
【问题讨论】:
-
你检查过这个答案吗:stackoverflow.com/a/54825603/1318946
-
你有没有机会使用firebase?如果是,最新版本在 android X 上,因此错误
-
@Ggriffo 不。我没有使用 Firebase。
-
当我的项目未迁移到 androidX 时遇到此错误,我尝试同步 CameraX 库。迁移后一切正常。
标签: java android android-gradle-plugin android-manifest androidx