android-libraries: [Bug] Lottie package throwing error while creating the release build in Android after switching to target framework 13
Android application type
Classic Xamarin.Android (MonoAndroid12.0, etc.)
Affected platform version
Xamarin Android 13
Description
While trying to release the application in Android after switching the target framework to 13 getting Lottie package error.
Microsoft.Extensions.Hosting3.1.10 Microsoft.Extensions.Http3.1.10 Microsoft.Identity.Client4.29.0 PlayCore1.8.0 Plugin.CurrentActivity2.1.0.4 Plugin.Permissions6.0.1 Xamarin.AndroidX.Browser1.5.0.3 Xamarin.AndroidX.AppCompat1.6.1.6 Xamarin.Firebase.Messaging123.3.1 Xamarin.Forms" Version=“5.0.0.2622” /> Xamarin.AndroidX.AppCompat.Resources1.1.0.2 Xamarin.AndroidX.Legacy.Support.Core.Utils" Version=“1.0.0.22” /> Xamarin.Essentials" Version=“1.8.0” /> Newtonsoft.Json13.0.1 Xamarin.Forms.PancakeView2.3.0.759 Com.Airbnb.Android.Lottie4.2.2 SkiaSharp.Svg1.60.0 SkiaSharp.Views.Forms2.88.6 SkiaSharp.Extended1.60.0 Microsoft.AppCenter.Analytics4.2.0 Microsoft.AppCenter.Crashes4.2.0 Autofac6.1.0 Refractored.MvvmHelpers1.6.2 Acr.UserDialogs7.1.0.483 Rg.Plugins.Popup2.0.0.11 Xamarin.Forms.Visual.Material5.0.0.2622 Xamarin.Google.Dagger2.27.0 Xamarin.GooglePlayServices.Base118.2.0.4 Xamarin.AndroidX.RecyclerView1.3.2.1 Xamarin.AndroidX.Collection1.3.0.2 Xamarin.AndroidX.Migration" Version=“1.0.10”
Relevant log output
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Legacy.targets(5,5): **Error XALNK7000: Mono.Linker.MarkException: Error processing method: 'AndroidX.Collection.SparseArrayCompat Com.Airbnb.Lottie.LottieComposition::get_Characters()' in assembly: 'Lottie.Android.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve AndroidX.Collection.SparseArrayCompat**
at Mono.Linker.Steps.MarkStep.HandleUnresolvedType (Mono.Cecil.TypeReference reference) [0x00013] in <43053c0ed9b14666903c480c1357d840>:0
at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x0002c] in <43053c0ed9b14666903c480c1357d840>:0
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00000] in <43053c0ed9b14666903c480c1357d840>:0
at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x0016c] in <43053c0ed9b14666903c480c1357d840>:0
at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x0001b] in <43053c0ed9b14666903c480c1357d840>:0
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00047] in <43053c0ed9b14666903c480c1357d840>:0
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue () [0x0000a] in <43053c0ed9b14666903c480c1357d840>:0
at Mono.Linker.Steps.MarkStep.Process () [0x000f6] in <43053c0ed9b14666903c480c1357d840>:0
at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x0000d] in <43053c0ed9b14666903c480c1357d840>:0
at MonoDroid.Tuner.MonoDroidMarkStep.Process (Mono.Linker.LinkContext context) [0x0000b] in <43053c0ed9b14666903c480c1357d840>:0
at Mono.Linker.Pipeline.ProcessStep (Mono.Linker.LinkContext context, Mono.Linker.Steps.IStep step) [0x0000d] in <43053c0ed9b14666903c480c1357d840>:0
at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x0000f] in <43053c0ed9b14666903c480c1357d840>:0
at MonoDroid.Tuner.Linker.Run (Mono.Linker.Pipeline pipeline, Mono.Linker.LinkContext context) [0x00000] in <43053c0ed9b14666903c480c1357d840>:0
at MonoDroid.Tuner.Linker.Process (MonoDroid.Tuner.LinkerOptions options, Mono.Linker.ILogger logger, Mono.Linker.LinkContext& context) [0x00071] in <43053c0ed9b14666903c480c1357d840>:0
at Xamarin.Android.Tasks.LinkAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver res) [0x0018f] in <43053c0ed9b14666903c480c1357d840>:0
at Xamarin.Android.Tasks.LinkAssemblies.RunTask () [0x0001b] in <43053c0ed9b14666903c480c1357d840>:0
at Microsoft.Android.Build.Tasks.AndroidTask.Execute () [0x00000] in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:17 (XALNK7000) (AppName.Android)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 26 (5 by maintainers)
we are seeing the issue
probably this closed issue solves it https://github.com/Baseflow/LottieXamarin/pull/399 But they don’t deploy it yet
Thanks for the feedback.
try explicitly adding
Xamarin.AndroidX.Collection.Jvm. It was bound 3 months ago and seems like google moved some classes to new maven artifact.https://www.nuget.org/packages/Xamarin.AndroidX.Collection.Jvm
For others running into this, there is an alternative library that is maintained by the Xamarin team, supports both Xamarin Forms and MAUI and seems fairly regularly updated. It worked well for our Xamarin Forms project and we will use that instead.
https://github.com/mono/SkiaSharp.Extended (must use prerelease nugets as of now)
This article was helpful although it explains for MAUI: https://cedricgabrang.medium.com/implementing-lottie-animations-in-your-net-maui-application-62bd484af651