dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.89k stars 524 forks source link

Upgrading xamarin-android to .Net8.0 - Error AMM0000 #8842

Open rj-jpl opened 3 months ago

rj-jpl commented 3 months ago

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

VS 2022 Version 17.9.3

Description

I am trying to upgrade our current Xamarin.Android project to a .Net8.0 https://learn.microsoft.com/en-us/dotnet/maui/migration/android-projects?view=net-maui-8.0

I am getting the following error:

AndroidManifest.xml(28,18): java.exe error AMM0000: C:\..........\obj\Debug\net8.0-android\lp\118\jl\AndroidManifest.xml Warning:
AndroidManifest.xml(28,18): java.exe error AMM0000:     Namespace 'androidx.versionedparcelable' used in: AndroidManifest.xml, AndroidManifest.xml.
AndroidManifest.xml(28,18): java.exe error AMM0000: 
AndroidManifest.xml(28,18): java.exe error AMM0000:     Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from AndroidManifest.xml:28:18-86
AndroidManifest.xml(28,18): java.exe error AMM0000:     is also present at AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
AndroidManifest.xml(28,18): java.exe error AMM0000:     Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:16:3-46:17 to override.
AndroidManifest.xml(28,18): java.exe error AMM0000: Directory 'obj\Debug\net8.0-android\lp\118' is from 'androidx.versionedparcelable.versionedparcelable.aar'.

I have spent several days to find the root cause but I had no success. We only have one AndroidManifest.xml file and I was not able to find any other AndroidManifest.xml file in the whole solution folder. So basically I am stuck now and any help is greatly appreciated.

Thanks

Steps to Reproduce

I don't think it easy for anyone to reproduce this issue because it seems to be related to our application settings and configuration regarding the NuGet packages or other reasons.

Did you find any workaround?

No workaround available.

Relevant log output

No response

jonathanpeppers commented 3 months ago

Can you share a .binlog file that contains the error? https://aka.ms/binlog

rj-jpl commented 3 months ago

Hi Jonathan, Thanks for looking at this. I am not sure if I can share the build log file in here. I have asked for a permission. However, in case I could not share that with you, is there any place I need to look at in the hope of finding the root cause? Thank you!

jonathanpeppers commented 3 months ago

The error message suggests:

AndroidManifest.xml(28,18): java.exe error AMM0000:     Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from AndroidManifest.xml:28:18-86
AndroidManifest.xml(28,18): java.exe error AMM0000:     is also present at AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
AndroidManifest.xml(28,18): java.exe error AMM0000:     Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:16:3-46:17 to override.
AndroidManifest.xml(28,18): java.exe error AMM0000: Directory 'obj\Debug\net8.0-android\lp\118' is from 'androidx.versionedparcelable.versionedparcelable.aar'.

Both androidx.versionedparceable and androidx.support.v4 have duplicate AndroidManifest.xml values. Can you completely remove any V4 Nuget packages? (Or update to latest?)

A lot of times apps are using this package, but don't actually need it: