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 ImagePicker fails to launch. Call to function 'ExponentImagePicker.launchCameraAsync' has been rejected.

See original GitHub issue

Summary

My users on Android arrive at a point where they can no longer launch the camera. User has given camera and media library permissions. User was able to open camera. User is no longer able to open Camera or Media Library.

It seems to be related to the expo task manager too.

** I’ve found that the issue appears when: **

  • Given you are tracking location via a task in the task manager
  • When you close the app
  • When you reopen the app
  • When you try to pick an image
  • Then the image picker will not open

I’ve found that the issue does not appear when location tracking is not active when the app was last closed.

Check the linked repo with reproducible example.

result = await ImagePicker.launchCameraAsync({
        base64: true,
        allowsEditing: true,
        mediaTypes: ImagePicker.MediaTypeOptions.Images,
        quality: 0.2
      });

// or

result = await ImagePicker.launchImageLibraryAsync({...})

Resulting error logs (source Sentry):

Error: Error: Call to function 'ExponentImagePicker.launchCameraAsync' has been rejected.
→ Caused by: java.lang.IllegalStateException: Attempting to launch an unregistered ActivityResultLauncher with contract expo.modules.imagepicker.contracts.CameraContra...
  at ? (app:///index.android.bundle:3411:1320)
  at generatorResume([native code])
  at n(app:///index.android.bundle:269:69)
  at p(app:///index.android.bundle:269:316)
  at u(app:///index.android.bundle:2634:157)
  at ? (app:///index.android.bundle:2634:884)
  at ? (app:///index.android.bundle:76:1692)
  at p(app:///index.android.bundle:76:528)
  at N(app:///index.android.bundle:76:918)
  at callReactNativeMicrotasks(app:///index.android.bundle:76:3079)
  at value(app:///index.android.bundle:56:2935)
  at ? (app:///index.android.bundle:56:1045)
  at value(app:///index.android.bundle:56:2583)
  at value(app:///index.android.bundle:56:1004)
  at value([native code])
  at value([native code])

Closing and reopening the app does not resolve the issue. Once a user has met this error, only reinstalling the app works.

What platform(s) does this occur on?

Android

Environment

expo-env-info 1.0.5 environment info: System: OS: macOS 12.0.1 Shell: 3.2.57 - /bin/bash Binaries: Node: 16.12.0 - ~/.nvm/versions/node/v16.12.0/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.1.0 - ~/.nvm/versions/node/v16.12.0/bin/npm Watchman: 2021.06.07.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 IDEs: Android Studio: 4.1 AI-201.8743.12.41.7199119 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild npmPackages: expo: ^46.0.0 => 46.0.9 react: 18.0.0 => 18.0.0 react-dom: 18.0.0 => 18.0.0 react-native: 0.69.6 => 0.69.6 react-native-web: ~0.18.7 => 0.18.8 react-navigation: ^4.4.4 => 4.4.4 npmGlobalPackages: eas-cli: 0.53.1 expo-cli: 6.0.6 Expo Workflow: managed

Minimal reproducible example

The error appears only for production builds and dev builds using a dev-client.
I’ve been able to reproduce it via the example demo app in this github repository: https://github.com/Nxtra/expo-image-picker-issue-reproduce

The steps to reproduce the exact issue are in the repo, also here:

  • run npx expo start
  • open via dev client
  • Press “pick an image”
  • You will be able to pick an image
  • Select start tracking
  • After a few sec an icon will appear in you top notification bar indicating that you are being tracked
  • Close the app (really close it by swiping it out of your open apps menu)
  • Open app
  • Press “pick an image”
  • The camera picker won’t open!

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:11

github_iconTop GitHub Comments

3reactions
russnescommented, Oct 26, 2022

I’m also experiencing the same issue, although I haven’t been as thorough in reproducing it in these steps. Now after deleting the app and reinstalling from Google Play, it appears to work. Testing on a galaxy S9, with versions:

"react": "18.0.0",
"expo-image-picker": "13.3.1",
"react-native": "0.69.6",
3reactions
rgonzalez-clicohcommented, Oct 21, 2022

Some news?

I have the same problem and the same steps to replicate it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Call to function 'ExponentImagePicker ... - Stack Overflow
I believe the error may be due to incompatibility with other expo modules but I'm not sure because I have not updated or...
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 >
How to use the expo-image-picker.launchCameraAsync ...
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 >
Possible Unhandled Promise Rejection (id: 0): | Mendix Forum
The javascript action below has been tested with ... isEnabled(); if (!enabled) { throw(new Error("NFC staat niet aan")); } } return new ...
Read more >
Using Image Picker and Camera in React Native (Expo)
The result will be displayed right below the buttons. If you're using Safari, this demo video might not work nicely or not start...
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