unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.82k stars 710 forks source link

Bump Xamarin.AndroidX.AppCompat dependency at least to 1.2.0.7 #6477

Closed queequac closed 2 years ago

queequac commented 3 years ago

After using the latest Xamarin.Essentials to version 1.7, my build is broken due to a linker error (I am using linking for "SDK and user assemblies"). Initially I was assuming this is related to Xamarin.Essentials, but I was told this would be because of an outdated dependency in Uno. (See https://github.com/xamarin/Essentials/issues/1850#issuecomment-880850107)

Uno makes use of Xamarin.AndroidX.AppCompat 1.1.0 which depends on Xamarin.AndroidX.Core 1.1.0. These dependencies need to be bumped as there was an issue in older 1.1.0 with an accessbility namespace that had a typo and this was fixed in Xamarin.AndroidX.Core 1.3.2.2.

Please bump your Xamarin.AndroidX.AppCompat dependency at least to 1.2.0.7.

Current behavior

Using Xamarin.Essentials 1.7 and Uno.UI 1.8.13 breaks a build when linking "SDK and user assemblies"

Expected behavior

Builds without any errors. ;-)

How to reproduce it (as minimally and precisely as possible)

Creating a project with Xamarin.Essentials 1.7 and Uno.UI 1.8.13 should be sufficient. Personally I have AOT+LLVM+StartupTracing activated, but in my tests only the linking option was the problem.

Workaround

Stay on Xamarin.Essentials 1.6.1

Works on UWP/WinUI

Yes, Android only.

Environment

Nuget Package:

Nuget Package Version(s): 1.8.13 (most likely previous versions either)

Affected platform(s):

IDE:

Relevant plugins:

Anything else we need to know?

jeromelaban commented 3 years ago

Thanks for the report.

Bumping the version of this package will introduce a hard breaking change with other applications. We generally do AndroidX updates only when absolutely necessary, and generally once a year when a newer version of Android is released (monoandroid12.0 I would presume if that ever happens for Xamarin targets).

Can you provide the linker exception you're getting ?

queequac commented 3 years ago

Made it work again by manually adding Xamarin.AndroidX.RecyclerView 1.2.1. So it should be sufficient of you bump that dependency and not AppCompat. Or is that a hard breaking change either? :)

The linker error was in the referenced issue, but here you go again:

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000: Mono.Linker.MarkException: Error processing method: 'System.Void AndroidX.RecyclerView.Widget.RecyclerView/LayoutManager::n_OnInitializeAccessibilityNodeInfo_Landroidx_recyclerview_widget_RecyclerView_Recycler_Landroidx_recyclerview_widget_RecyclerView_State_Landroidx_core_view_accessibility_AccessibilityNodeInfoCompat_(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)' in assembly: 'Xamarin.AndroidX.RecyclerView.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve AndroidX.Core.View.Accessibiity.AccessibilityNodeInfoCompat
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Mono.Linker.Steps.MarkStep.ProcessQueue()
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    --- End of inner exception stack trace ---
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Mono.Linker.Steps.MarkStep.ProcessQueue()
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Mono.Linker.Steps.MarkStep.Process()
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Mono.Linker.Pipeline.Process(LinkContext context)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Xamarin.Android.Tasks.LinkAssemblies.RunTask()
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(643,5): error XALNK7000:    at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/builder/azdo/_work/2/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17
jeromelaban commented 3 years ago

Thanks for the update. Even updating any of the dependencies is a problem, as it causes a cascade of fine-tuning to make to AndroidX packages, sometimes in very subtle ways.

What we can do, though, is adjust the dependencies versions in the templates.

queequac commented 3 years ago

Whatever magic you can do to solve my linker error is fine.😉

In the meanwhile you'd recommend sticking to Xamarin.Essentials 1.6.1 or do you think adding the latest RecyclerView package to my project is safe enough if it builds and the apps seems to work (even though not having it tested intenively)?

jeromelaban commented 3 years ago

If the linker does not complain, and that the android tooling does not either, you're generally good to go!

jeromelaban commented 2 years ago

Updating to Android 12 and Uno 4.1 or later fixes this issue.