Skip to content

[net7-rc2] Building an app in Release configuration reports incorrect duplicate types #7473

Description

@jeromelaban

Android application type

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

Affected platform version

net7.0-rc2

Description

Building a net6.0-android app in Release configuration causes the following errors:

C:\hostedtoolcache\windows\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.476\tools\Xamarin.Android.Common.targets(1438,3): 
warning XA4214: The managed type `Microsoft.UI.Xaml.Controls.AnimatedIcon` exists in multiple assemblies: Uno.UI, Uno.UI, Uno.UI, Uno.UI. Please refactor the managed type names in these assemblies so that they are not identical. [C:\a\1\s\UnoAppAll\UnoAppAll.Mobile\UnoAppAll.Mobile.csproj::TargetFramework=net6.0-android]

then java-related errors:

C:\hostedtoolcache\windows\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.476\tools\Xamarin.Android.Common.targets(1438,3): 
error XA4215: The Java type `crc64a5a37c43dff01024.GridViewHeaderItem` is generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. [C:\a\1\s\UnoAppAll\UnoAppAll.Mobile\UnoAppAll.Mobile.csproj::TargetFramework=net6.0-android]

Steps to Reproduce

  1. dotnet new install Uno.ProjectTemplates.Dotnet
  2. dotnet new unoapp -o testapp
  3. cd testapp\testapp.Mobile
  4. dotnet build -f net6.0-android -c Release

Notice a very large number of errors after the AOT step:

C:\hostedtoolcache\windows\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.476\tools\Xamarin.Android.Common.targets(1438,3): 
warning XA4214: The managed type `Microsoft.UI.Xaml.Controls.AnimatedIcon` exists in multiple assemblies: Uno.UI, Uno.UI, Uno.UI, Uno.UI. Please refactor the managed type names in these assemblies so that they are not identical. [C:\a\1\s\UnoAppAll\UnoAppAll.Mobile\UnoAppAll.Mobile.csproj::TargetFramework=net6.0-android]

then java-related errors:

C:\hostedtoolcache\windows\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.476\tools\Xamarin.Android.Common.targets(1438,3): 
error XA4215: The Java type `crc64a5a37c43dff01024.GridViewHeaderItem` is generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. [C:\a\1\s\UnoAppAll\UnoAppAll.Mobile\UnoAppAll.Mobile.csproj::TargetFramework=net6.0-android]

Did you find any workaround?

No, bumping to net7.0-android did not fix the issue. Considering the number of times the duplicate assembly is found, this would look like the number of target CPU architectures ?

Relevant log output

msbuild.zip

Activity

  1. jeromelaban commented on Oct 20, 2022

    @jeromelaban
    Author

    Update: Building with -p:RuntimeIdentifier=android-arm64 makes the error go away, but only builds for one CPU architecture.

  2. dellis1972 commented on Oct 20, 2022

    @dellis1972
    Contributor

    We probably need to add some additional logic to check for assemblies in the different runtime directories.

  3. jeromelaban commented on Oct 20, 2022

    @jeromelaban
    Author

    @dellis1972 would you know of a possible workaround for this (even if it means changing the targets files) ?

  4. dellis1972 commented on Oct 20, 2022

    @dellis1972
    Contributor

    @jeromelaban the check is done within the Task GenerateJavaStubs. https://github.com/xamarin/xamarin-android/blob/main/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs#L191

    The problem is GenerateJavaStubs is getting ALL of the assemblies for each RuntimeIdentifier. So we end up with 4 entires for Uno.UI etc and others.

    I guess you could write a target which runs just before the _GenerateJavaStubs target which will remove those duplicates from @(_ResolvedAssemblies) and @(_ResolvedUserMonoAndroidAssemblies) .. but I'm not sure how that would effect the packaging as those same ItemGroups are used to package the final app. https://github.com/xamarin/xamarin-android/blob/main/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets#L1477

    You might be able to add a filter to that target locally and make copies of those ItemGroups which you then pass to GenerateJavaStubs. (effectively replacing the @(_ResolvedAssemblies) and @(_ResolvedUserMonoAndroidAssemblies) for that target, but leaving those ItemGroups intack for the other targets.

  5. added a commit that references this issue on Oct 20, 2022
    642bee0
  6. added 5 commits that reference this issue on Nov 1, 2022
    52e2d7d
    df4b905
    5fa7c0b
    741fe34
    68ef6eb
  7. 15 remaining items

  8. added a commit that references this issue on Nov 22, 2022
    0736c57
  9. liveinvarun commented on Nov 28, 2022

    @liveinvarun

    @dellis1972 Any update on when this will be fixed. Currently the release build is broken when we target .net7 based workloads for android.

  10. dellis1972 commented on Nov 28, 2022

    @dellis1972
    Contributor

    We have a fix (see #7477) just having issues getting the unit tests green so it can be merged.

  11. added a commit that references this issue on Nov 28, 2022
    3415f67
  12. jeromelaban commented on Nov 29, 2022

    @jeromelaban
    Author

    🚀🚀 Thanks for the work on fixing this issue!

  13. jeromelaban commented on Dec 15, 2022

    @jeromelaban
    Author

    @jonpryor Would you know when this update will be released? It does not seem to be part of an SR1 update (only iOS and macOS were updated, for what I could see). Thanks!

  14. jonathanpeppers commented on Dec 15, 2022

    @jonathanpeppers
    Member

    This fixed missed the cutoff date but should be in the next one.

    The .NET 7 release branch is: https://github.com/xamarin/xamarin-android/tree/release/7.0.1xx

  15. queequac commented on Jan 10, 2023

    @queequac

    Obviously also not fixed in today's VS 17.4.4 release. :(

  16. jeromelaban commented on Jan 19, 2023

    @jeromelaban
    Author

    Fixed in 17.5 Preview 3!

  17. jonathanpeppers commented on Jan 19, 2023

    @jonathanpeppers
    Member

    You also should be able to run dotnet workload update. This will also be in 17.5 GA.

  18. queequac commented on Feb 2, 2023

    @queequac

    With updated workloads and Uno 4.7.37 it finally works even in VS17.4.4. I am able to publish targeting .net7 with AOT enabled. 😄

  19. ghost locked as resolved and limited conversation to collaborators on Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions