0

I'm using react-native-camera (https://github.com/lwansbrough/react-native-camera) to take photos in React Native. But I'm getting an error when I try to take a photo. The error that I get is Error creating media file

My code is as follows:

class TakePicture extends Component {
    takePicture() {
        this.camera.capture({target: Camera.constants.CaptureTarget.disk})
            .then((data) => this.props.pictureTaken(data);)
            .catch(err => console.error(err));
    }

    render() {
        return (
            <View style={styles.container}>
                <Camera
                    ref={(cam) => this.camera = cam;}
                    style={styles.preview}
                    aspect={Camera.constants.Aspect.Fill}>
                </Camera>

                <View style={styles.footer}>
                    <View style={styles.footerButton}>
                        <TouchableHighlight onPress={this.takePicture.bind(this)} underlayColor='#ff1c4d'>
                            <View style={styles.contentFooterButton}>
                                <Icon
                                    name='ios-camera-outline'
                                    size={25}
                                    style={styles.icon}/>
                                <Text style={styles.footerButtonText}>Picture</Text>
                            </View>
                        </TouchableHighlight>
                    </View>
                </View>
            </View>
        );
    }
}

I'm using:

  • node v6.9.1
  • react-native: 0.41.2
  • Android simulator : Android 6.0

Thus when I call takePicture() I get this error.enter image description here

Any advice?

Boky
  • 11,554
  • 28
  • 93
  • 163

0 Answers0