如何在我的React Native应用程序中显示gif?

时间:2018-04-15 12:24:40

标签: android react-native

我使用react-native init AwesomeProject创建了一个应用。

尽管遵循https://facebook.github.io/react-native/docs/image.html中的说明,我仍然无法显示gif。当我评论compile 'com.facebook.fresco:animated-gif:1.8.1'我的应用运行正常时。

我的build.gradle依赖项部分:

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile 'com.facebook.fresco:animated-gif:1.8.1' // For animated GIF support
}

我使用的是Windows 10和一款针对8.1的Android模拟器。当我运行react-native run-android时出现错误" AwesomeProject已停止"。

1 个答案:

答案 0 :(得分:1)

您应该尝试使用此功能来显示.gif

最好的。

https://github.com/airbnb/lottie-react-native