android: [net7-rc2] Building an app in Release configuration reports incorrect duplicate types
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
dotnet new install Uno.ProjectTemplates.Dotnetdotnet new unoapp -o testappcd testapp\testapp.Mobiledotnet 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
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 25 (12 by maintainers)
Commits related to this issue
- [Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid is the same. Fixes #7473 With the new build system under `dotnet` we can end up with duplicate assemblies for different `Runtime... — committed to dellis1972/xamarin-android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid is the same. Fixes #7473 With the new build system under `dotnet` we can end up with duplicate assemblies for different `Runtime... — committed to dellis1972/xamarin-android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid is the same. Fixes #7473 With the new build system under `dotnet` we can end up with duplicate assemblies for different `Runtime... — committed to dellis1972/xamarin-android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid is the same. Fixes #7473 With the new build system under `dotnet` we can end up with duplicate assemblies for different `Runtime... — committed to dellis1972/xamarin-android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid is the same. Fixes #7473 With the new build system under `dotnet` we can end up with duplicate assemblies for different `Runtime... — committed to dellis1972/xamarin-android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid is the same. Fixes #7473 With the new build system under `dotnet` we can end up with duplicate assemblies for different `Runtime... — committed to dellis1972/xamarin-android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid is the same. Fixes #7473 With the new build system under `dotnet` we can end up with duplicate assemblies for different `Runtime... — committed to dellis1972/xamarin-android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid is the same. Fixes #7473 With the new build system under `dotnet` we can end up with duplicate assemblies for different `Runtime... — committed to dellis1972/xamarin-android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid is the same. Fixes #7473 With the new build system under `dotnet` we can end up with duplicate assemblies for different `Runtime... — committed to dellis1972/xamarin-android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid is the same. Fixes #7473 With the new build system under `dotnet` we can end up with duplicate assemblies for different `Runtime... — committed to dellis1972/xamarin-android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Don't report duplicate type if the mvid is the same. Fixes #7473 With the new build system under `dotnet` we can end up with duplicate assemblies for different `Runtime... — committed to dellis1972/xamarin-android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Fix XA4215 if AssemblyName is the same (#7477) Fixes: https://github.com/xamarin/xamarin-android/issues/7473 Context: https://github.com/xamarin/monodroid/commit/4c69... — committed to dotnet/android by dellis1972 4 years ago
- [Xamarin.Android.Build.Tasks] Fix XA4215 if AssemblyName is the same (#7477) Fixes: https://github.com/xamarin/xamarin-android/issues/7473 Context: https://github.com/xamarin/monodroid/commit/4c69... — committed to dotnet/android by dellis1972 4 years ago
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. š
šš Thanks for the work on fixing this issue!
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
We have a fix (see https://github.com/xamarin/xamarin-android/pull/7477) just having issues getting the unit tests green so it can be merged.
@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.