Expo ImagePicker fails to launch. Call to function 'ExponentImagePicker.launchCameraAsync' has been rejected.
See original GitHub issueSummary
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:
- Created a year ago
- Comments:11
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:
Some news?
I have the same problem and the same steps to replicate it.