You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[net7-rc2] Building an app in Release configuration reports incorrect duplicate types #7473
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
dotnet new install Uno.ProjectTemplates.Dotnet
dotnet new unoapp -o testapp
cd testapp\testapp.Mobile
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 ?
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.
@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!
Activity
jeromelaban commentedon Oct 20, 2022
Update: Building with
-p:RuntimeIdentifier=android-arm64makes the error go away, but only builds for one CPU architecture.dellis1972 commentedon Oct 20, 2022
We probably need to add some additional logic to check for assemblies in the different runtime directories.
jeromelaban commentedon Oct 20, 2022
@dellis1972 would you know of a possible workaround for this (even if it means changing the targets files) ?
dellis1972 commentedon Oct 20, 2022
@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
_GenerateJavaStubstarget 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#L1477You 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.[Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid…
[Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid…
[Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid…
[Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid…
[Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid…
[Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid…
15 remaining items
[Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid…
liveinvarun commentedon Nov 28, 2022
@dellis1972 Any update on when this will be fixed. Currently the release build is broken when we target .net7 based workloads for android.
dellis1972 commentedon Nov 28, 2022
We have a fix (see #7477) just having issues getting the unit tests green so it can be merged.
[Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid…
[Xamarin.Android.Build.Tasks] Fix XA4215 if AssemblyName is the same (#…
jeromelaban commentedon Nov 29, 2022
🚀🚀 Thanks for the work on fixing this issue!
[Xamarin.Android.Build.Tasks] Fix XA4215 if AssemblyName is the same (#…
jeromelaban commentedon Dec 15, 2022
@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!
jonathanpeppers commentedon Dec 15, 2022
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
queequac commentedon Jan 10, 2023
Obviously also not fixed in today's VS 17.4.4 release. :(
jeromelaban commentedon Jan 19, 2023
Fixed in 17.5 Preview 3!
jonathanpeppers commentedon Jan 19, 2023
You also should be able to run
dotnet workload update. This will also be in 17.5 GA.queequac commentedon Feb 2, 2023
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. 😄