Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 492
M.Paul D Avatar asked Jun 29 '18 10:06

M.Paul D


2 Answers

Try to downgrade from 2.7.0 to 2.6.3

like image 81
Anand Avatar answered Sep 19 '22 13:09

Anand


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.

like image 44
Alireza Sattari Avatar answered Sep 18 '22 13:09

Alireza Sattari