Getting turned down by Permissions.askAsync(Permissions.CAMERA_ROLL)


#1

Hi,

I’m struggling a bit with using the camera on Android. And… I get a feeling I’m not alone?

  • Expo V31

  • Detached

Permissions.askAsync(Permissions.CAMERA_ROLL) returns denied, no dialog to grant permissions is showed.

Permissions.askAsync(Permissions.CAMERA) seems to be working fine - shows dialog, returns granted when supposed to.

ImagePicker.launchCameraAsync- no action, never returns or opens camera.

ImagePicker.launchImageLibraryAsync- works as expected.

askPermissionsAsync = async () => {
  const p1 = await Permissions.askAsync(Permissions.CAMERA);
  const p2 = await Permissions.askAsync(Permissions.CAMERA_ROLL);
};

chooseImage = async () => {
  await this.askPermissionsAsync();
  const result = await ImagePicker.launchImageLibraryAsync({
    allowsEditing: true,
    aspect: [4, 3]
  });
...

snapPhoto = async () => {
  await this.askPermissionsAsync();
  const result = await ImagePicker.launchCameraAsync({
    allowsEditing: true,
    aspect: [4, 3]
  });
...

Asking for permissions returns:

p1: Object
  expires :"never"
  permissions : Object
  status :"granted"

p2: Object
  expires :"never"
  permissions : Object
  status :"denied"

Has someone else run across this?

Cheers // Kristofer


askAsync SMS permissions return denied
Issue on iOS Standalone TestFlight: Permissions.getAsync(Permissions.NOTIFICATIONS) returns status as granted always.
#2

@adamjnav and @Expo, any thoughts on below and above?

This line:

await this.askPermissionsAsync();

Generates this warning:

Possible Unhandled Promise Rejection (id: 0):
Error: User rejected permissions

The thing is, no dialog to grant permissions is ever shown. Or that is, one dialog shows - the one for the CAMERA_ROLL permission, not for CAMERA.

Best // Kristofer


#3

Seems I found a way to fix it by manually editing AndroidManifest.xml.

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove"/>

to:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

@adamjnav, @bacon etc, isn’t this edit supposed to happen automatically when ejecting or when doing expo publish based on the permissions settings in app.json? In any case, editing manually worked fine in this instance, took me ages though to realise to try this seemingly simple fix. If the intention is to edit the manifest manually, possibly a clarification in the docs would be helpful.

Cheers // Kristofer


#4

Hi @fmckl - I just created a new blank project, ejected it, and my AndroidManifest.xml file had the correct lines –

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

I am curious if your project was ejected recently, or if it was ejected on an older version of Expo and you just upgraded to SDK 31. If you can find a reliable way to reproduce getting the tools:node="remove" in the AndroidManifest file I’d love to know about it!


#5

Yup, same here, I have not been able to reproduce it. I ejected when expo V31 was just a day old, possibly there was some glitch in the 31.0.0 version causing this?

It seems Gradle adds these “merge rule markers” when merging two manifests during the build process. Could a situation arise when the ejected project has more than one manifest file?

https://developer.android.com/studio/build/manifest-merge

//K


#6

Interesting – it’s possible that an early version of the 31.0.0 template had some sort of dependency issue that caused this. Let us know if you see it again.


closed #7

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