Lottie 错误:“Java.Lang.IllegalStateException:'无法解析组合'”

问题描述 投票:0回答:6

当我尝试将 gif 加载到我的项目时突然返回错误:

Java.Lang.IllegalStateException: 'Unable to parse composition'

图片了解更多link

我想将 gif 插入我的项目我尝试使用 Lottie 和 Json 文件

到目前为止我的代码

<forms:AnimationView 
    x:Name="animationView" 
    Grid.Row="1"
    Animation="first.json" 
    Loop="false" 
    AutoPlay="false"/>
xamarin xamarin.forms visual-studio-2019
6个回答
3
投票

我的情况:升级到最新版本,因为旧的Lottie不支持旧的json格式

implementation "com.airbnb.android:lottie:6.0.0"

2
投票

就我而言,我将

app:lottie_url
替换为
app:lottie_rawRes
,效果很好


1
投票

请将

xmlns:lottie="clr-namespace:Lottie.Forms;assembly=Lottie.Forms"
添加到您的 XAML 头部并使用此组件

 <lottie:AnimationView 
                x:Name="AnimationView" 
                Animation="first.json" 
                AutoPlay="True" Loop="true"
                VerticalOptions="FillAndExpand"
                HorizontalOptions="FillAndExpand" />

并且不要忘记在 MainActivity 和 AppDelegate 上初始化

AnimationViewRenderer.Init();


0
投票

需要确定json

Android:

DroidProject/Assets/filename.json
,如 AndroidAsset

iOS:

iOSProject/filename.json
,如 BundleResource


0
投票

lottie.setAnimation("");
未设置或为空白时发生此错误


0
投票

就我而言,Lottie 文件已损坏(我错误地替换了 Lottie 文件源代码中的一些代码)。我用正确的 Lottie 文件替换了它,然后它就工作了。

© www.soinside.com 2019 - 2024. All rights reserved.