This repository was archived by the owner on Jun 16, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
This repository was archived by the owner on Jun 16, 2023. It is now read-only.
Getting "Attempt to invoke virtual method ... on a null object reference" error while capturing #522
Copy link
Copy link
Closed
Labels
staleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.
Description
While capturing a photo on React Native 0.39.1 / Android 7
my component/app crashes with the error listed below
Code
takePicture() {
this.camera.capture()
.then((data) => {
const image = {
uri: data.path,
height: 640,
width: 480
};
ExpenseActions.updateValues({key: 'photo', value: image});
this.context.navigator.forward('ConfirmPhotoToExpense');
})
.catch(err => console.error(err));
}
...
render() {
const cameraIconSize = 22;
const cameraIconName = 'camera';
return (
<View style={cameraStyles.container}>
<Camera
ref={(cam) => {this.camera = cam;}}
style={cameraStyles.preview}
captureTarget={Camera.constants.CaptureTarget.temp}
orientation="portrait">
<View style={cameraStyles.capture}>
<View style={[styles.icon, cameraStyles.cameraIcon]}>
<Icon
name={cameraIconName}
color={WHITE} size={cameraIconSize}
onPress={() => this.takePicture()}
/>
</View>
</View>
</Camera>
<View style={cameraStyles.photoGrid}>
{this.state.photos.map(this.renderImage)}
</View>
</View>
);
}
Error
Throws this beauty
/AndroidRuntime: FATAL EXCEPTION: main
Process: com.awesomeproject, PID: 2962
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.drew.metadata.Directory.containsTag(int)' on a null object reference
at com.lwansbrough.RCTCamera.RCTCameraModule.fixOrientation(RCTCameraModule.java:576)
at com.lwansbrough.RCTCamera.RCTCameraModule.access$300(RCTCameraModule.java:45)
at com.lwansbrough.RCTCamera.RCTCameraModule$3.onPictureTaken(RCTCameraModule.java:668)
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1092)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
12-18 18:34:08.874 1563-1902/system_process W/ActivityManager: Force finishing activity com.awesomeproject/.MainActivity
Chat Conversation End
wardnath, harryfyodor, joe-lloyd, fzyzcjy and ArturTimoxin
Metadata
Metadata
Assignees
Labels
staleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.