Why am I getting an 'AnimationViewRenderer doesn't exist in the context' error in Xamarin Forms for Android?
Asked Answered
O

4

8

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.

Outbreed answered 29/6, 2018 at 10:39 Comment(0)
A
5

Try to downgrade from 2.7.0 to 2.6.3

Airburst answered 8/2, 2019 at 9:43 Comment(0)
T
5

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.

Taxis answered 2/6, 2020 at 5:32 Comment(0)
A
2

With latest version of Com.Airbnb.Xamarin.Forms.Lottie, you do not need to call AnimationViewRenderer.Init(); anymore.

Aforementioned answered 1/9, 2021 at 8:13 Comment(0)
R
1

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/

Rote answered 29/6, 2018 at 15:59 Comment(2)
I did that @Bruno but AnimationViewRenderer.Init(); is showing error. It says AnimationViewRenderer doesnot exist in this context.Outbreed
You have all the packages installed, in both Forms and .Android project? Check your project if the Lottie package is actually installed.Rote

© 2022 - 2024 — McMap. All rights reserved.