Xamarin.Android、AndroidManifest.xml、AndroidManifestMerger、xmlns:tools 架构,始终手动替换

Giu*_*lli 2 android android-manifest xamarin.android xamarin xamarin.forms

在编译我的 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)
Run Code Online (Sandbox Code Playgroud)

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

但是每当我编译我的 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

Yve*_*ves 10

这是Xamarin Forms 4.6.0.967 及更高版本的问题。对我来说,它是由使用 Honeywell.BarcodeReader NuGet 包引起的。

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

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

<application android:label="@string/app_name" tools:replace="android:label" ...
Run Code Online (Sandbox Code Playgroud)

或者如果有更多冲突:

<application android:label="@string/app_name" tools:node="replace"...
Run Code Online (Sandbox Code Playgroud)

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

xmlns:tools="http://schemas.android.com/tools"
Run Code Online (Sandbox Code Playgroud)