0

I have an issue with android. The file in the Android assets directory is not found.

Error:

Error while updating property 'sourceName' of a view managed by: LottieAnimationView

null

Unable to find file loading.js

Animation file location:

app/src/main/assets/loading.json

Component:

class Loading extends Component {

  componentDidMount() {
    this.animation.play()
  }

  render() {
    return (
      <View style={StyleSheet.loading.page}>
        <View style={StyleSheet.loading.animationWrapper}>
          <Animation
            ref={animation => { this.animation = animation }}
            style={StyleSheet.loading.animation}
            loop
            source="loading.json"
          />
        </View>
        <Text style={StyleSheet.loading.text}>LOADING</Text>
      </View>
    )
  }
}

Versions:

"lottie-react-native": "2.2.0"
"react-native": "0.47.2"
TylerH
  • 20,799
  • 66
  • 75
  • 101
Lee
  • 5,816
  • 6
  • 45
  • 61

1 Answers1

0

you should add your loading.json file in your javascript source code and require it

<Animation
   ref={animation => { this.animation = animation }}
   style={StyleSheet.loading.animation}
   loop
   source={require('./loading.json')}
/>
TylerH
  • 20,799
  • 66
  • 75
  • 101
Mohamed Khalil
  • 3,036
  • 1
  • 20
  • 26