MAUI Migration - Xamarin.Android.Common.targets error XA4215

Andrew S Bissada 10 Reputation points
2024-01-30T16:55:48.5366667+00:00

I have an app I migrated from Xamarin.Android to .NET MAUI Android. I am getting the following error. I don't understand why, as the app is MAUI so why would anything Xamarin show up? (Xamarin.Android.Common.Targets - what is this? I can't find it on google search). Its not even in the directory for the solution/project:

Error XA4215 The Java type mono.android.support.v4.media.session.MediaSessionCompat_OnActiveChangeListenerImplementor is generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. AndroidAppCore C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.43\tools\Xamarin.Android.Common.targets

Developer technologies | .NET | .NET MAUI
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Holroyd 0 Reputation points
    2025-01-14T22:11:14.5266667+00:00

    Same issue I think:

    System.NullReferenceException: Object reference not set to an instance of an object.
       at Java.Interop.Tools.Cecil.CustomAttributeProviderRocks.<GetCustomAttributes>d__3.MoveNext() in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/CustomAttributeProviderRocks.cs:line 30
       at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
       at Android.App.ApplicationAttribute.FromCustomAttributeProvider(ICustomAttributeProvider provider, TypeDefinitionCache cache) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Mono.Android/ApplicationAttribute.Partial.cs:line 60
       at Xamarin.Android.Tasks.ManifestDocument.CreateApplicationElement(XElement manifest, String applicationClass, List`1 subclasses, TypeDefinitionCache cache) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs:line 581
       at Xamarin.Android.Tasks.ManifestDocument.Merge(TaskLoggingHelper log, TypeDefinitionCache cache, List`1 subclasses, String applicationClass, Boolean embed, String bundledWearApplicationName, IEnumerable`1 mergedManifestDocuments) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs:line 290
       at Xamarin.Android.Tasks.GenerateJavaStubs.MergeManifest(NativeCodeGenState codeGenState, Dictionary`2 userAssemblies) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs:line 351
       at Xamarin.Android.Tasks.GenerateJavaStubs.Run(Boolean useMarshalMethods) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs:line 270
       at Xamarin.Android.Tasks.GenerateJavaStubs.RunTask() in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs:line 102
       at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25
    
    0 comments No comments

  2. Bruce (SqlWork.com) 78,006 Reputation points Volunteer Moderator
    2025-01-14T23:03:26.05+00:00

    Maui is a port of Xamarin. While the Xamarin Forms has had namespace changes, many of the Xamarin libraries and tools have the old namespace. Just pay attention to the error message.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.