'Expo Image Picker -- not returning image from Android Emulator in Android Studio

I am running the Pixel 5 API 30 avd in Android Studio with react native client coding.

I am using the expo image picker to pick the image and return to the application.

The code is :

  const handleUpload = async () => {
    //application needs to ask for permission
    let permissionResult =
      await ImagePicker.requestMediaLibraryPermissionsAsync();

    // return;
    if (permissionResult.granted === false) {
      alert("Camera access is required");
      return;
    }
    let pickerResult = await ImagePicker.launchImageLibraryAsync({
      allowsEditing: true,
      aspect: [4, 3],
      base64: true,
    });

    console.log(pickerResult);
    if (pickerResult.cancelled === true) {
      return;
    }
    // save to state for preview
    let base64Image = `data:image/jpg;base64,${pickerResult.base64}`;
    setUploadImage(base64Image);
    // send to backend for uploading to cloudinary
  };

It is all good -- I give permission and then have taken pictures with the android simulator to create an image bank on the emulator.

However, when I select the image -- expected behaviour is for the function to return to the caller and the image to be selected. All I can do is, however keep clicking the image randomly -- it doesn't seem to 'select' it and return.

Any suggestions?

Further info on the Expo image picker here:

https://docs.expo.dev/tutorial/image-picker/

thx! Karen



Solution 1:[1]

You just need to select the crop (top right) -- as the code passing the option to 'allowEditing' --- to retun from the function.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 karentut