lottie-react-native: Cannot get any Lottie animations to show in an Expo SDK 48 React Native app.

Description

Cannot get any Lottie animations to show in an Expo SDK 48 React Native app.

Steps to Reproduce

  1. Install lottie-react-native as described by Expo docs here (we are using the managed workflow)
  2. Add LottieView as described within the Expo docs:

<LottieView autoPlay ref={animation} style={{ width: 200, height: 200, backgroundColor: '#eee', }} source={require('./assets/gradientBall.json')} /> 3. I have tried the various solutions suggested by this thread to no luck or avail.

Expected behavior: See Lottie Animation on screen. One thing to mention is that we are using development-client builds for Expo, so NOT the Expo Go app. We’re also using the hermes engine if that means anything.

Actual behavior: Expect to see Lottie animation on screen but the area is occupied and I can see the background but there is no animation. It never plays and never appears.

Versions

"lottie-react-native": "5.1.4", "react": "18.2.0", "react-dom": "18.2.0", "react-native": "0.71.3",

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 40

Commits related to this issue

Most upvoted comments

I am working on releasing v6 and communicating with expo to increase the recommended version and that should fix all the issues for all expo users. Stay tuned!

Lottie is now updated for Expo Go in the next release of Expo SDK. However, those who are using Expo Prebuilt should not have any problems. Cheers!

@matinzd have you update the package? I am still getting the error with expo 48

This issue still persists for 6.0.0-rc.6 and Expo 48. We cannot get any animations to run at all and have also tried all solutions mentioned by @hasanjafri.

I can confirm that the new way of downloading lotties will crash android devices in expo go SDK 49. Also only version 5.1,6 of lottie will show animations / play it. With a json from the “old way” of downloading animations.

Updated version of lottie for Expo Go will be available in SDK 50. Since then, there is no way for Expo Go users to prevent this crash. Try downgrading to v5 or use Expo custom dev client or bare RN. This issue is NOT about Expo Go.

Just install lottie again. npx expo install lottie-react-native

I followed this documentation today and got a total of 4 lottie animations to work in my React Native Expo project: https://docs.expo.dev/versions/latest/sdk/lottie/ The only piece code you have to replace is: const animation = useRef(null); Change it to: const animation = useRef<LottieView>(null) to resolve the errors related to the animation.current?.reset(); and animation.current?.play() lines of code.

I will say however that I did have a problem with one lottie animation .json file not working and crashing the app when used. It was downloaded like a month or two ago, and it seems to have disappeared from lottie’s catalog of animations. This animation .json file seems to be an outlier because I tried about 10+ other animations, all of which worked.

Hope this helps and stay blessed!

Also, I want to thank all the hard-working folks at Lottie who have been working to fix the issue of lottie animations not rendering. Thank you for putting your time and energy into resolving this issue.

Expo v49.0.0 React Native v0.72.3 Lottie-React-Native v5.1.6

It also crashes in android all the time . but just wondering why its not showing at all . Maybe try wrapping LottieView inside a View and give flex:1 like below

<View style={{ flex: 1 }}>
        <LottieView
          ref={confettiRef}
          source={require("../../assets/lottie/confettiLottie.json")}
          style={{
            width: Dimensions.get("window").width - 100,
            height: Dimensions.get("window").height - 20,
          }}
          autoPlay={false}
          loop={false}
          resizeMode="cover"
        />
      </View>

or try using Lottie instead of LottieView (same manner) .

Which version are you using? Are you running it with dev client?