首页 > 解决方案 > 加载图像和 GIF 时如何修复应用程序崩溃?

问题描述

我想在特定状态下加载 2 个 gif 和 2 个图像(png),但是在加载其中一些后应用程序崩溃了,所以突然关闭了我用 android studio 调试应用程序并遇到内存不足的问题我该怎么做才能解决这个问题?

反应原生版本:0.57.2

平台:Android 开发操作系统:Windows 10

这只是我的渲染代码的一部分

 ....
 <Animated.Image
  source={
    this.props.nextDone && this.props.selectedOptionId !== null
      ? gifEndGuage[
          this.state.prvSelectionOptionId * 10 +
            this.props.selectedOptionId
        ]
      : this.props.selectedOptionId !== null
      ? pathsGif[
          this.state.prvSelectionOptionId * 10 +
            this.props.selectedOptionId
        ]
      : this.state.guageImage
  }
  style={{
    width: '100%',
    height: '100%',
    resizeMode: 'contain',
    backgroundColor: 'transparent',
    opacity: this.state.gifState
  }}
/>

<Animated.Image
  source={
    this.props.selectedOptionId !== null
      ? pathsPng[this.props.selectedOptionId]
      : this.state.selectedGuagePng
  }
  style={{
    width: '100%',
    height: '100%',
    resizeMode: 'contain',
    backgroundColor: 'transparent',
    opacity: this.state.pngState,
    position: 'absolute'
  }}
/>
 ....

标签: androidreact-native

解决方案


推荐阅读