requestPermissionsAsync fails silently

I am running the following code on SDK Version 43 on Android emulator using expo go

console.log('checking access')

try {
  const { status } = await MediaLibrary.requestPermissionsAsync();
  if (status !== 'granted') {
    console.log('no access')
    return;
  }
  console.log('status ok')
}
catch (ex) {
  console.log('no access: exception')
}

My output is
checking access

The call to requestPermissionsAsync fails silently but the app still works. I have the following android permissions defined in app.json.

"VIBRATE",
"CAMERA",
"WRITE_EXTERNAL_STORAGE",
"READ_EXTERNAL_STORAGE",
"CAMERA_ROLL"

Any idea what could be the problem and how this is even possible (that it fails silently without any exception)?

Created a new empty project. An exception is being thrown first time code is run. Seems as some native module is missing.

[Error: Encountered an exception while calling native method: Exception occurred while executing exported method requestPermissionsAsync on module ExponentMediaLibrary: String resource ID #0xffffffff]

Anyone got any idea what is missing?

share the project on github so someone else can run it

Here is a simple project showing the issue. Install npm modules and run expo start

https://github.com/innoware-mx/medialibrary

that app does not have any code in it outside of the default template and does not include expo-media-library

sorry, you are right. i have updated git, it is there now

i cloned the project and ran it and i was prompted for a permission as expected

Wow, that is weird. Did you run it in the android emulator using expo go?

yup, exactly

Thanks for your help, it helped me narrow down the culprit.

Turns out, my android VM was corrupt. After installing a new one, everything works!

2 Likes

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