Skip to content

[net6] Building an application can sometimes cause Xamarin.Android.Tasks.TypeMapGenerator.GenerateRelease to fail #7302

@jeromelaban

Description

@jeromelaban

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

17.3.0

Description

Building an app can sometimes cause this:

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.451\tools\Xamarin.Android.Common.targets(1438,3): error XAGJS7004: System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Xamarin.Android.Tasks.TypeMapGenerator.GenerateRelease(Boolean skipJniAddNativeMethodRegistrationAttributeScan, List`1 javaTypes, String outputDirectory, ApplicationConfigTaskState appConfState)
   at Xamarin.Android.Tasks.GenerateJavaStubs.WriteTypeMappings(List`1 types, TypeDefinitionCache cache)
   at Xamarin.Android.Tasks.GenerateJavaStubs.Run(DirectoryAssemblyResolver res)
   at Xamarin.Android.Tasks.GenerateJavaStubs.RunTask()
   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 17

Steps to Reproduce

  1. Build an app
  2. ? (maybe have a build failure of some kind)
  3. Rebuild, see the failure above.
  4. Clean bin/obj
  5. Rebuild, the build will succeed.

Did you find any workaround?

Cleaning bin/obj folders.

Relevant log output

android-build-failure.zip

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.needs-triageIssues that need to be assigned.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions