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.

TylerH
  • 20,799
  • 66
  • 75
  • 101
M.Paul D
  • 91
  • 1
  • 6

4 Answers4

5

Try to downgrade from 2.7.0 to 2.6.3

Anand
  • 1,866
  • 3
  • 26
  • 49
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.

Alireza Sattari
  • 181
  • 2
  • 12
2

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

TylerH
  • 20,799
  • 66
  • 75
  • 101
Nguyen Minh Hien
  • 455
  • 7
  • 10
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/

Bruno Caceiro
  • 7,035
  • 1
  • 26
  • 45
  • 3
    I did that @Bruno but AnimationViewRenderer.Init(); is showing error. It says AnimationViewRenderer doesnot exist in this context. – M.Paul D Jul 02 '18 at 07:12
  • You have all the packages installed, in both Forms and .Android project? Check your project if the Lottie package is actually installed. – Bruno Caceiro Jul 02 '18 at 13:21