Share via

Issue with transitive package from Plugin.Firebase - Xamarin.GoogleAndroid.Annotations

Sreenivasan, Sreejith 780 Reputation points
2026-05-14T13:12:01.66+00:00

I am facing below errors when rebuild the project after the .net 10 upgrade from .net 8:

The Java type android.annotation.TargetApi is generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. The Java type android.annotation.SuppressLint is generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted.   android.annotation.TargetApi generated by: Android.Annotation.ITargetApi, Xamarin.GoogleAndroid.Annotations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null   android.annotation.TargetApi generated by: Android.Annotation.ITargetApi, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065   android.annotation.SuppressLint generated by: Android.Annotation.ISuppressLint, Xamarin.GoogleAndroid.Annotations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null   android.annotation.SuppressLint generated by: Android.Annotation.ISuppressLint, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065

Screenshot:
User's image

But I am not using Xamarin.GoogleAndroid.Annotations in my project. After analysis I found this package is coming from as a transitive package from Plugin.Firebase.

I did the upgrade to .net 10 to resolve the 16KB memory page warning from Google Play, and the due date is May 31 2026.

I implemented the push notification using this firebase plugin package.

So what should I do to resolve this issue? Do I need to remove the Plugin.Firebase package and implement the push notification in another way?
Plugin.Firebase version: 4.2.1

Please let me know for any other details. The due date is approaching, please suggest a solution for this issue ASAP.

Developer technologies | .NET | .NET Multi-platform App UI

1 answer

Sort by: Most helpful
  1. Jack Dang (WICLOUD CORPORATION) 17,905 Reputation points Microsoft External Staff Moderator
    2026-05-15T08:06:39.44+00:00

    Hi @Sreenivasan, Sreejith ,

    Thanks for reaching out.

    From my research, this behavior is likely a package compatibility issue introduced after moving to .NET 10 for Android. The platform bindings already include the Android annotation types, but Plugin.Firebase 4.2.1 is still bringing in Xamarin.GoogleAndroid.Annotations transitively.

    As a result, the build ends up with two different assemblies attempting to generate the same Java types, which leads to the XA4215 errors you’re seeing.

    A good first step is to keep Plugin.Firebase in place and try excluding the transitive annotations package from the Android build. You can do that by adding an explicit reference in your .csproj like this:

    <ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
      <PackageReference Include="Xamarin.GoogleAndroid.Annotations"
                        Version="1.0.0"
                        ExcludeAssets="all"
                        PrivateAssets="all" />
    </ItemGroup>
    

    After applying that, clear any cached artifacts and rebuild to make sure the previous resolution isn’t reused:

    dotnet nuget locals all --clear
    dotnet clean
    dotnet restore
    dotnet build -f net10.0-android
    

    If you want to confirm where the package is coming from, you can run:

    dotnet list package --include-transitive
    

    That should show Xamarin.GoogleAndroid.Annotations being pulled in through Plugin.Firebase or one of its dependencies.

    If excluding the package alone doesn’t resolve it, the next thing to check is whether there are newer versions of Plugin.Firebase or its Firebase/AndroidX dependencies that are aligned with .NET 10. In many cases, updating to compatible versions resolves these duplicate binding issues more cleanly than workarounds.

    As a fallback, it’s also possible to remove the conflicting assembly at build time via a custom MSBuild step, but that approach is more fragile and typically only used when dependency alignment isn’t possible.

    Given your deadline, I would start with the exclusion approach since it’s low impact and quick to validate, then look at dependency updates if the issue persists. I wouldn’t recommend removing Plugin.Firebase unless these options don’t resolve the conflict, as that would require reworking your push notification implementation.

    Hope this helps! If my answer was helpful, I would greatly appreciate it if you could follow the instructions here so others with the same problem can benefit as well.

    Was this answer helpful?


Your answer

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