反应本机相机不会在第二次调用时工作

react native camera wont work on second invokation

React 原生相机在 Android 中的第二次调用中不起作用。在第二次调用时,应用程序崩溃。 我在用 本机反应:0.56.0 反应原生相机:1.6.4 当我使用最新版本的 react-native-camera 时也是如此。 我无法将 react-native 更新到最新版本,因为我有另一个与最新版本不兼容的包 它在模拟器上工作正常,只有真实设备有问题

The --scan result is

我的相机屏幕

class CameraScreen extends Component {
  constructor(props) {
    super(props);
    this.state = {
      boltIconIsPressed: false,
    };
  }

  renderError() {
    Alert.alert(
      'Error',
      'Something went wrong, Try again!',
      [
        { text: 'Ok', style: 'cancel' },
      ],  
    );
    this.props.navigation.goBack();
  }

render() {
    if (this.props.isFocused) {
    return (
      <View style={styles.container}>
        <RNCamera
          ref={ref => {
            this.camera = ref;
          }}
          style={styles.preview}
          type={RNCamera.Constants.Type.back}
          flashMode={this.state.boltIconIsPressed ? RNCamera.Constants.FlashMode.off : RNCamera.Constants.FlashMode.on}
          onMountError={this.renderError.bind(this)}
          permissionDialogTitle={'Permission to use camera'}
          permissionDialogMessage={'We need your permission to use your camera phone'}
        />
        <View 
          style={{ flex: 0, 
                   flexDirection: 'row', 
                   justifyContent: 'center',
                   backgroundColor: 'transparent' }}
        >
          <Button
             outline
             rounded
             style={styles.capture}
             onPress={() => this.props.navigation.navigate('gallery')}
          >
            <Icon
              type='Entypo'
              name='image'
              style={{ color: '#862d59', }}
            />
        </Button>

          <Button
            outline
            rounded
            onPress={this.takePicture.bind(this)}
            style={styles.capture}
          >
            <Icon
              type='SimpleLineIcons'
              name='camera'
              style={{ color: '#862d59', }}
            />
          </Button>

          <Button
            outline
            rounded
            style={styles.capture}
            onPress={() => this.setState({ boltIconIsPressed: 
                       !this.state.boltIconIsPressed })}
          >
            <Icon
              type='MaterialCommunityIcons'
              name={this.state.boltIconIsPressed ? "flash-off" : "flash"}
              style={{ color: '#862d59', }}
            />
          </Button>
          </View>
         </View>
    );
   }
    return (
        <View />
      );
  }
  takePicture = async function () {
    let data = null;
    if (this.camera) {
      const options = { 
        width: 1800,
        base64: true,
      };
      console.log(data);
      data = await this.camera.takePictureAsync(options);
      this.props.navigation.navigate('uploadscreen', {
        image: data,
      });
    }
  };
}
export default withNavigationFocus(CameraScreen);

提前致谢

我收到这个错误是因为我没有存储空间来保存拍摄的图像。要使其工作,请将其添加到 AndroidManifest.xml 文件

android:largeHeap="true"