Camera Permission not workin in deployed version of the app Android only

Please provide the following:

  1. SDK Version: 39
  2. Platforms(Android/iOS/web/all): Android only

The app works fine in both iOS and Android in emulators and local device from the expo client. If I build it and release, it works fine in iOS but it does not work in android.

It does ask for camera permission (android does not ask for camera_roll permissions right?), but then it resolves the askAsync as DENIED no idea why.

My app.json android:

    "android": {
      "package": "myappname",
      "versionCode": 11,
      "permissions": [
        "CAMERA",
        "RECORD_AUDIO",
        "READ_PHONE_STATE",
        "READ_CONTACTS"
      ]
    }

The helper I am hacking around to get it working is in this messy state (but works in iOS and locally):

const checkPermission = async () => {
  let { status } = await Permissions.getAsync(
    Permissions.CAMERA,
    Permissions.CAMERA_ROLL
  );
  if (status !== 'granted') {
    const grantedPermissions = await Permissions.askAsync(
      Permissions.CAMERA,
      Permissions.CAMERA_ROLL
    );
    if (grantedPermissions.status === 'granted') return true;
  }
  if (status === 'granted') return true;
  return false;
};

I dumped the Permissions object in the released app, it has Camera as granted but cameraRoll.status as denied.

Why is it denying the cameraRoll without even ask?

Edit1: It might be something related to this issue: [ImagePicker] [SDK 37] CAMERA_ROLL Permission Missing · Issue #9079 · expo/expo · GitHub

But my project is a managed one.

Edit2: I’ve tried this to try to filter out where the issue is:

const checkPermission = async () => {
  if (Platform.OS === 'ios') {
    const { status } = await Permissions.getAsync(
      Permissions.CAMERA,
      Permissions.CAMERA_ROLL
    );
    if (status === 'granted') return true;
    if (status !== 'granted') {
      const grantedPermissions = await Permissions.askAsync(
        Permissions.CAMERA,
        Permissions.CAMERA_ROLL
      );
      if (grantedPermissions.status === 'granted') return true;
    }
  }
  if (Platform.OS === 'android') {
    const { status } = await Permissions.getAsync(Permissions.CAMERA);
    if (status === 'granted') return true;
    if (status !== 'granted') {
      const grantedPermissions = await Permissions.askAsync(Permissions.CAMERA);
      if (grantedPermissions.status === 'granted') return true;
    }
  }
  return false;
};

This way, in android, the app now asks for permission, it now won’t save it as denied (so one issue is that the askAsync is resolving to denied), but, it now saves the permissions as status = undetermined, with camera status granted but cameraRoll as undetermined. The weird part is that now I can access the galery, but the camera doesnt show up, not even a button asking what camera app to use, it simple asks if you want to use camera or gallery and does nothing if you chose camera!

Ok, this issue is really weird and I feel the expo team should take a look as there might be edge cases in android that are not working. I got it to work in the standalone version by adding these permissions to app.json:

        "READ_EXTERNAL_STORAGE",
        "READ_INTERNAL_STORAGE",
        "WRITE_EXTERNAL_STORAGE"
3 Likes

thanks @morenomdz it solved my problem

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.