java - Android X:tools:replace 在 line:for 属性中指定,但没有指定新值
问题描述
我在这个网站上尝试了很多解决方案,但问题仍然没有解决。问题是由于 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 指定了替换,但没有指定新值应用程序主清单(此文件),第 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 库。
将以下行添加到gradle.properties文件
android.useAndroidX=true
android.enableJetifier=true
tools:replace="android:appComponentFactory"
从清单中删除。
替换android.support.v7.app.AppCompatActivity
为androidx.appcompat.app.AppCompatActivity
推荐阅读
- highcharts - 是否可以设置刻度间隔的像素宽度?
- python - 如何在 Python Matplotlib 中为我的雷达图点添加标签
- sql - 将 .txt 文件加载到 Postgres 数据库中
- python - 尝试学习如何实现单个神经元
- vue.js - VueJS - 悬停时切换列表项的背景图像
- datetime - 将 Win32 纪元的纳秒添加到 Go 时间
- javascript - 如何有条件地加载和运行 javascript 文件
- c# - Asp Net Core 3.1 自定义角色授权
- c# - 为什么我使用此代码时没有显示任何内容?
- scala - Intellij IDEA - 无法为 Scala 添加框架支持