Why doesn't AnimationViewRenderer exist in the context error when trying to add Lottie animation in Xamarin forms Android project's MainActivity.cs? I am using Visual Studio 2017.
After installing Lottie version 3.1.2 for Xamarin.Forms I had the same issue. The reason was that this specific version of Lottie has a dependency on Mono runtime version 10 but my Android project was Mono version 9. So once I upgraded MonoAndroid to 10, everything was working fine and I could use AnimationViewRenderer.Init()
. However, I did not even need to initialize AnimationViewRenderer
; I just add the Lottie XAML component to my page and it is working perfectly.
You can check what version of Mono your Lottie requires by going to NuGet package manager, selecting the package and underneath Dependencies
you should be able to see the required MonoAndroid version.
With latest version of Com.Airbnb.Xamarin.Forms.Lottie
, you do not need to call AnimationViewRenderer.Init(); anymore.
You will need to add
AnimationViewRenderer.Init();
After initialising Forms in Android MainActivity.
A good post explaining the whole process: https://xamgirl.com/lottie-animations-step-by-step-in-xamarin-forms/
© 2022 - 2024 — McMap. All rights reserved.