Реагировать на родную камеру не будет работать при втором вызове

Встроенная камера React не будет работать при втором вызове в Android. При втором вызове приложение вылетает. я использую реагировать-родной: 0.56.0 реагировать на родную камеру: 1.6.4 То же самое, когда я использую последнюю версию react-native-camera. Я не могу обновить response-native до последней версии, потому что у меня есть другой пакет, который несовместим с последней версией и На эмуляторе работает нормально, проблема только с реальными устройствами

Результат --scan

Экран моей камеры

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.info(data);
      data = await this.camera.takePictureAsync(options);
      this.props.navigation.navigate('uploadscreen', {
        image: data,
      });
    }
  };
}
export default withNavigationFocus(CameraScreen);

заранее спасибо

0
0
493
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Я получил эту ошибку, потому что у меня нет хранилища для сохранения сделанного изображения. Чтобы он заработал, добавьте это в файл AndroidManifest.xml.

android:largeHeap = "true"

Другие вопросы по теме