Aris Guimerá
Aris Guimerá

Reputation: 1017

How to check if lottie animation works?

Im trying to do a simple loading with lottie. I found this animation: https://lottiefiles.com/18563-cooking#_=_

  <com.airbnb.lottie.LottieAnimationView
            android:id="@+id/animation_view"
            android:layout_width="200dp"
            android:layout_height="200dp"
            app:lottie_autoPlay="true"
            app:lottie_loop="true"
            app:lottie_rawRes="@raw/test"
            />

It's stored in SRC/Main/res/raw but I get this error:

You must set an images folder before loading an image. Set it with LottieComposition#setImagesFolder or LottieDrawable#setImagesFolder

I try to add to assets folder with app:lottie_fileName

So I think the animation is bug, because of this I want to know if exist some tools or command to know if animation works.

Upvotes: 3

Views: 7514

Answers (1)

wxkly
wxkly

Reputation: 1391

in my case ,my lottie json file contains code fragment like this:

{  
 "id": "image_0", 
 "w": 1241,
 "h": 802,  
 "u": "images/", 
 "p": "image_01.png",  
 "e": 0
}

it means it need image image_01.png to work. and it will look for it from folder images/.

if you don't provide this images folder location it will throw this exception.

here is the step i solved my problem.

  1. add the folder images into assets folder, the folder sturcture:
+-assets

+----images

---------image_01.png
  1. add app:lottie_imageAssetsFolder="images"in the xml( or

you can addsetImageAssetsFolder("/images");in code. )

Upvotes: 5

Related Questions