LottieView关闭android上的应用程序,并在IOS上运行
当在expo中使用lottie和react native时,所有动画都可以在ios上运行,但会使android上的应用程序崩溃。我缺少的安卓系统有什么特别的东西吗 我已经创建了一个新项目,并通过处理文档中的代码来复制该问题LottieView关闭android上的应用程序,并在IOS上运行,android,react-native,expo,lottie,Android,React Native,Expo,Lottie,当在expo中使用lottie和react native时,所有动画都可以在ios上运行,但会使android上的应用程序崩溃。我缺少的安卓系统有什么特别的东西吗 我已经创建了一个新项目,并通过处理文档中的代码来复制该问题 从“React”导入React; 从“react native”导入{按钮、样式表、视图}; 从“lottie react native”导入LottieView; 导出默认类App扩展React.Component{ componentDidMount(){ 这个.anim
从“React”导入React;
从“react native”导入{按钮、样式表、视图};
从“lottie react native”导入LottieView;
导出默认类App扩展React.Component{
componentDidMount(){
这个.animation.play();
//或使用以下命令设置特定的开始帧和结束帧:
//这个。动画。播放(30120);
}
重置动画=()=>{
this.animation.reset();
这个.animation.play();
};
render(){
返回(
{
这个动画=动画;
}}
风格={{
宽度:400,
身高:400,
背景颜色:“#eee”,
}}
source={require('./assets/gradientBall.json')}
//或查找更多乐蒂文件@https://lottiefiles.com/featured
//只需单击您喜欢的文件,将该文件放在左侧的“资产”文件夹中,并替换上面的“需要”语句
/>
);
}
}
运行纱线添加乐蒂反应-native@3.0.3或npm安装lottie react-native@3.0.3如果您正在使用Expo,则不能使用Lottie 3文件。从expo api参考()中:
"
已知问题:
乐天SDK目前被认为是世博会的“危险地带”,因为它的实现仍在Alpha中
导入Lottie 3文件会导致预览程序崩溃而不会出现可见错误,因为Expo依赖于Lottie react native v2。
“你有没有试过降低洛蒂的依赖程度?没有,你知道我会怎么做吗?谢谢!!!!你能解决这个问题吗?
import React from 'react';
import { Button, StyleSheet, View } from 'react-native';
import LottieView from "lottie-react-native";
export default class App extends React.Component {
componentDidMount() {
this.animation.play();
// Or set a specific startFrame and endFrame with:
// this.animation.play(30, 120);
}
resetAnimation = () => {
this.animation.reset();
this.animation.play();
};
render() {
return (
<View style={styles.animationContainer}>
<LottieView
ref={animation => {
this.animation = animation;
}}
style={{
width: 400,
height: 400,
backgroundColor: '#eee',
}}
source={require('./assets/gradientBall.json')}
// OR find more Lottie files @ https://lottiefiles.com/featured
// Just click the one you like, place that file in the 'assets' folder to the left, and replace the above 'require' statement
/>
<View style={styles.buttonContainer}>
<Button title="Restart Animation" onPress={this.resetAnimation} />
</View>
</View>
);
}
}