Lottie Animation doesn't appear on Android device - Xamarin Forms

不问归期 提交于 2021-01-20 12:10:23

问题


I'm using VS 2019 xamarin Forms, I recently watched some videos about how to use lottie animations and looks pretty simple. I'm doing every step but when I run the app the animation never appears.

Package Com.Airbnb.Lottie.Forms was added to all app projects (it's crossplatform) Then added Com.Airbnb.Android.Lottie to the Android app (first I tried without it, didn't work either)

This is the code

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             xmlns:lottie="clr-namespace:Lottie.Forms;assembly=Lottie.Forms"
             x:Class="AppWasher.MainPage">

    <StackLayout>
  
        <lottie:AnimationView
            x:Name="animationView"
            Animation="26617-ogad.json"
            RepeatMode="Restart"
            VerticalOptions="FillAndExpand"
            HorizontalOptions="FillAndExpand"
            WidthRequest="300"
            HeightRequest="300"/>
        
    </StackLayout>

</ContentPage>

This is the guide lottie provides

<forms:AnimationView
    x:Name="animationView"
    Animation="LottieLogo1.json"
    AnimationSource="AssetOrBundle"
    Command="{Binding ClickCommand}"
    RepeatCount="3"
    RepeatMode="Restart"
    VerticalOptions="FillAndExpand"
    HorizontalOptions="FillAndExpand" />

I tried using all those properties too, same result.

I'm testing on Android 9.0 version

Also json files were added to the assets folder in the android project and build action is set to AndroidAsset


回答1:


It works for me after i change the android Target Framework version to Android 10.0.

And i found the latest Lottie nuget depends on AndroidX.



来源:https://stackoverflow.com/questions/64561299/lottie-animation-doesnt-appear-on-android-device-xamarin-forms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!