Android 引入Airbnb Lottie框架後,報錯Error inflating class com.airbnb.lottie.LottieAnimationView

依賴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.LottieAnimationView
Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class com.airbnb.lottie.LottieAnimationView
Caused by: java.lang.reflect.InvocationTargetException


這是因爲沒有創建assets,用來存儲animated JSON files 。需要在 app/src/main/assets 這個路徑下創建assets文件夾


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章