Xamarin.Android, AndroidManifest.xml, AndroidManifestMerger, xmlns:tools schema, replace always manually

烂漫一生 提交于 2021-02-19 07:49:05

问题


When compile my Xamarin Forms Android application, visual studio, show me an error's list of AndroidManifest.xml conflict, for example:

/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)

So i open AndroidManifest.xml from debug folder, replace with tools:replace into application tag, add tools schema into manifest tag, save it, recompile my application and it run without error.

But WHENEVER i compile my Xamarin Forms Android application, must follow previous steps MANUALLY.

I also add <AndroidManifestMerger>manifestmerger.jar</AndroidManifestMerger>, into my Android .csproj

This issue is showed into DEBUG and RELEASE mode!!

Environment

  • Visual Studio Community 2019 for Mac Version 8.6.4
  • Xamarin Forms = 4.7.0.968
  • Xamarin.Android = Versione: 10.3.1.4

回答1:


This is an issue with Xamarin Forms 4.6.0.967 and above. To me, it was provoked by using the Honeywell.BarcodeReader NuGet package.

Some AndroidX packages were overwriting the default Xamarin (soon to be legacy) manifest merger with the manifestmerger.jar.

A workaround is to downgrade to Xamarin Forms 4.6.0.847, or to modify your AndroidManifest.xml to have an application element like this:

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

or if there are more conflicts:

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

You will also need to add the following namespace to the manifest as an attribute:

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



回答2:


Try cleaning and rebuilding your solution.

Build > Clean Solution

Build > Rebuild Solution

It worked for me.



来源:https://stackoverflow.com/questions/62487423/xamarin-android-androidmanifest-xml-androidmanifestmerger-xmlnstools-schema

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!