airbnb / lottie-android

Render After Effects animations natively on Android and iOS, Web, and React Native
http://airbnb.io/lottie/
Apache License 2.0
35.03k stars 5.41k forks source link

Android XML preview is not working if use lottie_url in XML only #2334

Closed gopalawasthi123 closed 1 year ago

gopalawasthi123 commented 1 year ago

Describe the bug Android studio XML preview is not working if we add the lottie_url in LottieAnimationView in XML only.

Steps To Reproduce

  1. Add a LottieAnimationView in android layout XML
  2. Add app:lottie_url="@string/some_url"
  3. Preview of Android layouts stop working

It cause problem in UI changes as have to remove app:lottie_url to see preview and make changes.

Android Studio Version: Android Studio Electric Eel | 2022.1.1 Patch 1

gpeal commented 1 year ago

The layout preview doesn't have access to the internet so I wouldn't expect this to work. You can try a tools: attribute if you'd like to override something for the layout preview.

shivamsoods commented 1 year ago

Hi This rendering issue is present even if we are accessing files from a local folder like raw. This seems to be an issue on new versions of Android Studio with Lottie Animations. IDE is not able to display dynamic structure in the preview window.

To overcome this, as @gpeal mentioned we can tool tools:. By using null, we only render the animations on runtime and not during the compile time.

In case from a raw folder we can :

<com.airbnb.lottie.LottieAnimationView
        ...
        app:lottie_rawRes="@raw/loading"
        tools:lottie_rawRes="@null"/>