Android 引入Airbnb Lottie框架后,报错Error inflating class com.airbnb.lottie.LottieAnimationView

来源:互联网 发布:淘宝上哪家药店是真的 编辑:程序博客网 时间:2024/06/05 20:57

依赖Lottie 后

compile 'com.airbnb.android:lottie:2.0.0-beta4'

添加LottieAnimationView控件

<com.airbnb.lottie.LottieAnimationView    android:id="@+id/animation_view"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    app:lottie_fileName="EmptyState.json"    app:lottie_loop="true"    app:lottie_autoPlay="true"    app:layout_constraintBottom_toBottomOf="parent"    app:layout_constraintLeft_toLeftOf="parent"    app:layout_constraintRight_toRightOf="parent"    app:layout_constraintTop_toTopOf="parent" />



运行后,发现报错

Caused by: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class com.airbnb.lottie.LottieAnimationViewCaused by: android.view.InflateException: Binary XML file line #14: Error inflating class com.airbnb.lottie.LottieAnimationViewCaused by: java.lang.reflect.InvocationTargetException


这是因为没有创建assets,用来存储animated JSON files 。需要在 app/src/main/assets 这个路径下创建assets文件夹


原创粉丝点击