Android X:tools:replace在第line:行指定属性,但未指定新值 [英] Android X: tools:replace specified at line: for attribute, but no new value specified
问题描述
我已经在此网站上尝试了许多解决方案,但是仍然无法解决问题.该问题归因于Android X库.当我添加Android X时,此问题已解决,但打开了新的问题.如何解决此问题?
I have tried many solutions on this website but still, the problem is not solved. The issue is due to Android X library. When I added Android X, this issue was resolved but it opened up new issue. How to fix this issue?
更早出现此错误:
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清单中):
Merging Error (in Android Manifest):
错误:在行:2中为属性指定的tools:replace android:appComponentFactory,但未指定新值app main 清单(此文件),第1行
Error: tools:replace specified at line:2 for attribute android:appComponentFactory, but no new value specified app main manifest (this file), line 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">
...
推荐答案
我认为您正在迁移到AndroidX库.
I think you are migrating to AndroidX libs.
将以下行添加到 gradle.properties 文件
android.useAndroidX=true
android.enableJetifier=true
从清单中删除tools:replace="android:appComponentFactory"
.
将android.support.v7.app.AppCompatActivity
替换为androidx.appcompat.app.AppCompatActivity
这篇关于Android X:tools:replace在第line:行指定属性,但未指定新值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!