In Android, taking a photo restarts the app without showing any error, however picking photos from gallery works fine.
RN: 0.48.3
react-native-image-picker: 0.26.7
Does you handle the permission ? Can you provide the crash stacktrace ?
+1
I have camera and photo, storage permissions
ios 10.3.2
RN: 0.50.3
react-native-image-picker: 0.26.7
com.android.tools.build:gradle:2.2.3
android version 6.0
this worked before with
RN 0.47.2
react-native-image-picker: 0.26.4
with all same other stacks
Same issue. At first we thought that was a react-native issue, and it might be, but now we're just confused: https://github.com/facebook/react-native/issues/16959
Ok, I found out that that's not a crash. It's the Android OS shutting all other intents, because the camera intent needs memory. DAAAMN. What can we do :S ?
@gengjiawen
for permissions, this is the AndroidManifest.xml
<manifest
xmlns:android="http://schemas.android.com/apk/res/android" package="com.metricstream.nucleus" android:versionCode="0" android:versionName="3.17.0">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="22"/>
<application android:name=".MainApplication" android:allowBackup="true" android:label="@string/app_name" android:icon="@mipmap/app_icon" android:theme="@style/AppTheme" android:exported="false" android:grantUriPermissions="true">
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
<meta-data android:name="io.fabric.ApiKey" android:value="d2911a2650eb8bb5e848b55727d74bbd5913addb"/>
<provider
xmlns:tools="http://schemas.android.com/tools" android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}" android:exported="false" android:grantUriPermissions="true" tools:replace="android:authorities">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/files" tools:replace="android:resource"/>
</provider>
</application>
</manifest>
here is the stacktrace,
E/InputEventReceiver: Exception dispatching input event.
E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
E/MessageQueue-JNI: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:583)
at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:557)
at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:399)
at com.imagepicker.utils.RealPathUtil.compatUriFromFile(RealPathUtil.java:31)
at com.imagepicker.ImagePickerModule.launchCamera(ImagePickerModule.java:257)
at com.imagepicker.ImagePickerModule.launchCamera(ImagePickerModule.java:206)
at com.imagepicker.ImagePickerModule$2.onTakePhoto(ImagePickerModule.java:162)
at com.imagepicker.utils.UI$1.onClick(UI.java:54)
at android.support.v7.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1046)
at android.widget.AdapterView.performItemClick(AdapterView.java:318)
at android.widget.AbsListView.performItemClick(AbsListView.java:1158)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3127)
at android.widget.AbsListView.onTouchUp(AbsListView.java:4054)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:3813)
at android.view.View.dispatchTouchEvent(View.java:11776)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2962)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2643)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:448)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1829)
at android.app.Dialog.dispatchTouchEvent(Dialog.java:815)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:71)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:410)
at android.view.View.dispatchPointerEvent(View.java:12015)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4795)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4609)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4200)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4166)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4293)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4174)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4350)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4200)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4166)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4174)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl
E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: com.metricstream.nucleus, PID: 4647
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:583)
at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:557)
at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:399)
at com.imagepicker.utils.RealPathUtil.compatUriFromFile(RealPathUtil.java:31)
at com.imagepicker.ImagePickerModule.launchCamera(ImagePickerModule.java:257)
at com.imagepicker.ImagePickerModule.launchCamera(ImagePickerModule.java:206)
at com.imagepicker.ImagePickerModule$2.onTakePhoto(ImagePickerModule.java:162)
at com.imagepicker.utils.UI$1.onClick(UI.java:54)
at android.support.v7.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1046)
at android.widget.AdapterView.performItemClick(AdapterView.java:318)
at android.widget.AbsListView.performItemClick(AbsListView.java:1158)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3127)
at android.widget.AbsListView.onTouchUp(AbsListView.java:4054)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:3813)
at android.view.View.dispatchTouchEvent(View.java:11776)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2962)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2643)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:448)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1829)
at android.app.Dialog.dispatchTouchEvent(Dialog.java:815)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:71)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:410)
at android.view.View.dispatchPointerEvent(View.java:12015)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4795)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4609)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4200)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4166)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4293)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4174)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4350)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4200)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4166)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4174)
E/AndroidRuntime: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6661)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6635)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6596)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6764)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:186)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:764)
D/ReactNative: ReactInstanceManager.detachViewFromInstance()
E/WindowManager: android.view.WindowLeaked: Activity com.metricstream.nucleus.MainActivity has leaked window DecorView@ce3eb76[] that was originally added here
at android.view.ViewRootImpl.(ViewRootImpl.java:485)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:346)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at android.app.Dialog.show(Dialog.java:330)
at com.imagepicker.ImagePickerModule.showImagePicker(ImagePickerModule.java:196)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:764)
Looks like fileProvider crash, I will give it a try to fix this. Do you familiar install package from github branch, I will need someone to help me test.
Please try to replace this dep with
npm install gengjiawen/react-native-image-picker#bugfix/android_photo_crash -S
@gengjiawen yes its working as desired with no issues.
can you please reflect these changes into your main project react-native-image-picker also.
I will create a pr https://github.com/react-community/react-native-image-picker/pull/763. And thanks for the feedback :)
@gengjiawen please,could u solve this issue, thanks!
https://github.com/react-community/react-native-image-picker/issues/762
Have tried replace this lib with my patch as I previously commented ?
@gengjiawen thanks for creating the pr and providing the fix :)
@gengjiawen
I follow those steps, it also crashes, no solved. https://github.com/react-community/react-native-image-picker/pull/763/commits/feaa947169fe184484bc53545f0f4b5a841b6e0d#diff-65d893f60222e839c1d2fd434200602d
my method might be able to solve this problem. #527
This repo seems to not be maintained anymore. Any light?
For me this one works:
npm install gengjiawen/react-native-image-picker#bugfix/android_photo_crash -S
Thanks!
Solved by downgrading the version of 'react-native-camera' from 1.0.3 into 0.12.0 works for me.
Interesting, I wonder what caused it.! @marcshilling any ideas?
I found a very efficient way to deal with this bug it seems :
Use the options maxWidth, maxHeight and/or quality to reduce the size of the pictures taken (depending on your use case, having pictures 3200x3200 might be useless). I found that for my need a 1200x1200 max + 0.9 quality works almost 100% of the time ! Hope this helps
@HadrienPierart
Thanks, bro it's working 👍 💯
hi, I added options maxWidth, maxHeight options but camera crash issue is not fixed for me. Please give any solution.
@harikanammi the same issue.
const options = {
title: 'Video Picker',
takePhotoButtonTitle: 'Take Video…',
mediaType: 'video',
storageOptions: {
skipBackup: true,
path: 'images'
},
videoQuality: 'low'
};
ImagePicker.showImagePicker(options, (response) => {
console.log('Response = ', response);
if (response.didCancel) {
console.log('User cancelled photo picker');
} else if (response.error) {
console.log('ImagePicker Error: ', response.error);
} else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
} else {
let source = { uri: response.uri };
this.setState({
videoSource: source,
videoURI: response.uri,
isOneVideoSelected: true
});
}
});
use this code working perfectly
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.
Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.
This seems to still be a problem. In our use case we need the high res images.. I noticed there are a lot of issues for this subject. Is this being looked at at the moment or should i aggregate all issues and reopen?
At the moment I use version 1.1.0 with RN 1.59 and this problem still persists with Xiaomi Redmi 8 and Samsung devices especially, for the configuration of the photos we use this configuration
const options = {
noData: false,
title: "Select an image",
cancelButtonTitle: "Cancel",
takePhotoButtonTitle: "Camera",
chooseFromLibraryButtonTitle: "Gallery",
mediaType: "photo",
quality: 0.5,
maxWidth: 1200,
maxHeight: 1200,
storageOptions: {
skipBackup: true,
cameraRoll: false
}
}
Can someone help me with this information, how could it be solved?
Thank you
Hi,
This issue still prevails. In android 9.0 when we launchCamera using react-native-image-picker it crashes for the first time but in subsequent calls it works fine.
Tried multiple options but nothing works.
react-native version is 0.62.0
react-native-image-picker is 2.3.1
Kindly let me know if anyone is facing this issue or if someone has resolved it.
I am also facing the same issues
react-native version is 0.61.4
react-native-image-picker is 2.3.1
Faced the same issue
react-native version is 0.63.2
react-native-image-picker is 2.3.3
Solution:
set options={quality: 0.9, maxWidth: 2400, maxHeight: 2400}
Facing the same issue
react-native version is ^0.63.3
react-native-image-picker is 2.3.3
Android OS 10
app restart without any error please help...
I am also facing the same issues, when i capture image using react-native-image-picker on iOS devices, sometimes my app is killed,
options = {
title: 'Add Photo',
quality: 0.8,
maxWidth: 800,
maxHeight: 800,
storageOptions: {
skipBackup: true,
}
}
react-native version is ^0.62.2
react-native-image-picker is 2.3.1
Most helpful comment
I found a very efficient way to deal with this bug it seems :
Use the options maxWidth, maxHeight and/or quality to reduce the size of the pictures taken (depending on your use case, having pictures 3200x3200 might be useless). I found that for my need a 1200x1200 max + 0.9 quality works almost 100% of the time ! Hope this helps