expo-image-picker crashes on Android after image is picked SDK 44
See original GitHub issueSummary
When picking an image on a standalone build (EAS), the app will crash/restart. The issue can be replicated in Expo Go when viewing the Snack by enabling the Developer Options > Don’t keep activities’ option.
The docs mention that Android likes to kill background processes and suggests to use ImagePicker.getPendingResultAsync() but offers no example on how this should be implemented. I’ve tried to implement it in a useEffect hook, before/after the image picking but the result is always the same, a crashed app.
It’s also worth mentioning I’m using Android 12 on a Samsung Galaxy S20 FE and it used to work fine with version 10.0.4. Also tested and failing with an Android Emulator - Android 9.
Thanks in advance!
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
Android - 12
SDK Version (managed workflow only)
44
Environment
Doesn’t matter as the problem is reproducible in Snack but here’s my local info.
expo-env-info 1.0.2 environment info: System: OS: Linux 5.4 Ubuntu 20.04.4 LTS (Focal Fossa) Shell: 5.0.17 - /bin/bash Binaries: Node: 14.18.2 - ~/.nvm/versions/node/v14.18.2/bin/node npm: 8.5.4 - ~/.nvm/versions/node/v14.18.2/bin/npm npmPackages: expo: ^44.0.0 => 44.0.6 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 react-navigation: ^4.4.4 => 4.4.4 npmGlobalPackages: eas-cli: 0.48.0 expo-cli: 5.3.0 Expo Workflow: managed
Reproducible demo
https://snack.expo.dev/@redxlll/image-picker
The Snack uses the exact same example code from the docs. Please note: Although this Snack uses Expo SDK 43 and expo-image-picker 11.0.3, the issue remains with SDK 44 and expo-image-picker 12.0.1.
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:11 (5 by maintainers)
I’m not sure why it’s necessary, I guess expo-image-picker should have a dependency on it but you should be able to fix it with:
Thanks for the suggestion will try it out later today, for now, I used a hacky way with
DocumentPicker
, yeah so anybody wondering if there is any workaround in a limited way you can use theDocumentPicker
like soAnd then you can handle the cancel event and the processing of the picked media files. It works for me just fine. Although I’m still contemplating the fact that it seems like both of them are some kind of
Native File Pickers
yet only one gives you the desired outcome for now.Also, I had one question is there a way in Expo either using
Image Picker
or any other expo package to let user pic pictures directly from camera roll like from the gallery app or something like that, for example in Instagram if you want to choose picture it either creates it’s own modal to display all your albums and camera roll itself, or there is a way to do it with expo package?