Giuseppe Novielli
Giuseppe Novielli

Reputation: 93

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

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

Upvotes: 4

Views: 8009

Answers (3)

user3225520
user3225520

Reputation: 1

To add to Yves answer....

It appears that the manifestmerger is not able to merge the AndroidManifest.xml from multiple projects in the Android solution.

When modifying your AndroidManifest.xml you may need to add multiple entries to the "tools:replace application tag such as label and theme.

<application 
   tools:replace="android:label, android:theme"
   android:label="XamarinDemo.Android" 
   android:theme="@style/MainTheme">
</application>

Upvotes: 0

Kingeh
Kingeh

Reputation: 39

Try cleaning and rebuilding your solution.

Build > Clean Solution

Build > Rebuild Solution

It worked for me.

Upvotes: 2

Yves
Yves

Reputation: 792

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"

Upvotes: 14

Related Questions