question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

expo-image-picker crashes on Android after image is picked SDK 44

See original GitHub issue

Summary

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:closed
  • Created a year ago
  • Reactions:4
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
mnightingalecommented, Apr 1, 2022

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:

npm install expo-image-loader
1reaction
AdrianJakubcikcommented, Apr 1, 2022

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:

npm install expo-image-loader

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 the DocumentPicker like so

result = await DocumentPicker.getDocumentAsync({
      type: ['image/*', 'video/*', 'application/x-mpegURL'],
      copyToCacheDirectory: true
    });

And 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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's causing Expo's ImagePicker.launchCameraAsync() to ...
See ImagePicker.getPendingResultAsync. However, the docs seem to be describing handling a crash occuring after taking a picture.
Read more >
expo-image-picker is crashing the app without any errors after ...
Just released a new version with the fix, you can install it by running expo client:install:android and selecting the SDK 41 option. Let...
Read more >
ImagePicker - Expo Documentation
expo -image-picker provides access to the system's UI for selecting images and videos from the phone's library or taking a photo with the...
Read more >
expo-image-picker - npm
Provides access to the system's UI for selecting images and videos from the phone's library or taking a photo with the camera. API...
Read more >
[Solved] App crashes when using Image Picker in iOS 12 [Aug ...
Testing on Android: Works as expected. Seems to be an iOS problem. 1 Like. jared ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found