You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xamarin Forms Android启动页Lottie 4.1解析组合失败求助

解决Xamarin Forms Android中Lottie 4.1的「Unable to parse composition」错误

你的xamarin.json文件必须设置特定的Build Action,当前设为None是错误的——这会导致Lottie无法定位并解析动画文件,正是触发Java.Lang.IllegalStateException的核心原因。

正确的设置步骤:

  • 右键点击项目中的xamarin.json文件
  • 打开「属性」面板
  • 将「生成操作」(Build Action)改为AndroidAsset

修改完成后,清理并重建项目,再运行即可正常加载Lottie动画。

你的布局代码参考:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.airbnb.lottie.LottieAnimationView
        android:id="@+id/animation_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:lottie_loop="false"
        app:lottie_speed="2.0"
        app:lottie_fileName="xamarin.json"
        app:lottie_autoPlay="true"/>
</LinearLayout>

内容的提问来源于stack exchange,提问作者JBD

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 05:33:29