android - Xamarin.Android、AndroidManifest.xml、AndroidManifestMerger、xmlns :tools schema, 始终手动替换

标签 android xamarin xamarin.forms xamarin.android android-manifest

在编译我的 Xamarin Forms Android 应用程序时,visual studio 向我显示 AndroidManifest.xml 冲突的错误列表,例如:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error AMM0000:  is also present at AndroidManifest.xml:14:9-41 value=(@string/app_name). (AMM0000)

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error AMM0000:  Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:19:3-79:17 to override. (AMM0000)

所以我从调试文件夹中打开 AndroidManifest.xml,替换为 tools:replace 到应用程序标签中,将工具模式添加到 list 标签中,保存它,重新编译我的应用程序,它运行没有错误。

但是每当我编译我的 Xamarin Forms Android 应用程序时,都必须手动执行前面的步骤

我还添加了 <AndroidManifestMerger>manifestmerger.jar</AndroidManifestMerger> , 进入我的 Android .csproj

此问题在 DEBUG 和 RELEASE 模式下显示!!

环境

  • Visual Studio Community 2019 for Mac 版本 8.6.4
  • Xamarin 表单 = 4.7.0.968
  • Xamarin.Android = 版本:10.3.1.4

最佳答案

这是一个 issue with Xamarin Forms 4.6.0.967 及以上版本。对我来说,它是由使用 Honeywell.BarcodeReader NuGet 包引起的。

一些 AndroidX 包正在用 manifestmerger.jar 覆盖默认的 Xamarin(即将成为旧版) list 合并。

解决方法是降级到 Xamarin Forms 4.6.0.847,或修改您的 AndroidManifest.xml 以具有如下应用程序元素:

<application android:label="@string/app_name" tools:replace="android:label" ...

或者如果有更多的冲突:

<application android:label="@string/app_name" tools:node="replace"...

您还需要将以下命名空间作为属性添加到 list 中:

xmlns:tools="http://schemas.android.com/tools"

关于android - Xamarin.Android、AndroidManifest.xml、AndroidManifestMerger、xmlns :tools schema, 始终手动替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62487423/

相关文章:

c# - Xamarin Forms 和 Prism Navigation 历史记录

android - 在某些 3G 网络上避免图像压缩

android - libtinyWRAP_neon.so 有文本重定位。这是在浪费内存并且存在安全风险。请修复

xamarin.ios - 是否可以使用 C# 以外的语言编译 MonoTouch 项目?

android - 带有 Xamarin 的 Visual Studio 2015 - VS 上未显示设备

c# - 自定义呈现器 DatePicker CountDownTimer 不会在 Xamarin 表单中更改值

c# - SQLite 中的 MissingMethodException

Android,将文件写入数据/数据/'package'文件夹的子目录的正确方法是什么

Android:如何仅在横向模式下打开前置摄像头?

android - 如何将 CreateDataBinding 导入 Xamarin