expo: imagePicker Crashing with Expo 31.0.0 Android 8.1

Environment

Expo CLI 2.4.1 environment info: System: OS: macOS 10.14.1 Shell: 3.2.57 - /bin/bash Binaries: Node: 9.4.0 - ~/.nvm/versions/node/v9.4.0/bin/node npm: 6.4.1 - ~/.nvm/versions/node/v9.4.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman IDEs: Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: expo: ^31.0.2 => 31.0.5 react: 16.5.0 => 16.5.0 react-native: https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz => 0.57.1 react-navigation: 1.5.11 => 1.5.11 npmGlobalPackages: expo-cli: 2.4.1

The device crashing is a Moto X4 Android 8.1

Steps to Reproduce

You can try the project here: https://expo.io/@receiptcoin/receiptchain

Taking a photo using the camera doesn’t crashes the app.

Here is the code I’m using

async componentDidMount() {
    console.log('camera screen mounted');
    const { status } = await Permissions.askAsync(Permissions.CAMERA);
    const cameraRollPermission = await Permissions.askAsync(Permissions.CAMERA_ROLL);
    const status_roll = cameraRollPermission.status;
    console.log('status and status camera is ' , status)
    console.log('status and status roll is ' , status_roll)
    if (status !== 'granted') {
      alert('Please grant app access to the camera so you can upload your photo.');
    }
    if (status_roll !== 'granted') {
      alert('Please grant app access to the camera roll so you can upload your photo.');
    }
    //this.takePhoto();
  }

  takePhoto = async () => {
    console.log('take photo called')
    const pickerResult = await ImagePicker.launchCameraAsync({
      allowsEditing: true,
      aspect: [4, 4],
      exif: true,
    });
    console.log('picker result is ' , pickerResult);
    this.handleImagePicked(pickerResult);

Both permissions are granted on the user’s moto X4, but the app still crashes upon the ImagePicker.launchCameraAsync call.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 11
  • Comments: 30 (7 by maintainers)

Most upvoted comments

Guys, do we have an update on this ? The problem persists.

Issue continues to persist for me.

The same thing happens both in the “lonely-cookies” snack and in my app on Nexus 5X (Android 8.1.0), no matter whether I run my app locally via expo-cli, or publish it to the Expo server. My version of Expo is 31.0.6.

I have the same problem on sdk 33 😦

I got this error on SDK 34

import * as ImagePicker from 'expo-image-picker';
ImagePicker.launchImageLibraryAsync-TypeError: undefined is not an object (evaluating 'n.ImagePicker.launchImageLibraryAsync')

I’ve created PR which optimize ImagePicker. However, I doubt that will help in this case.

I’m still struggling with reproducing this bug. Could someone provide logs from a device? It will help a lot.

To do this:

  • Enable USB debugging in your device.
  • Connect the device to the computer
  • Use these commands:
    • adb devices (to get your device id)
    • adb -s <id> logcat --pid=$(adb shell pidof -s <your package name>) (Expo client package name: host.exp.exponent)

not sure but after using expo publish my app can work

Same problem with launchImageLibraryAsync. The test was performed on the LG-H324 with Android 5.0 and Meizu M6 with Android 7.0. The code has not been changed and is taken from https://docs.expo.io/versions/v32.0.0/sdk/imagepicker/ and from https://snack.expo.io/ The application is closed and restarted sometimes after editing and cropping a photo, sometimes immediately after selecting a photo.

Could you please try reproducing this issue on SDK32? The problem may have been fixed in-between. 🙃