Why does Expo Bare Workflow Android Project automatically grant the File and Media Permission?

Viewed 258

Problem: I just updated my React-Native/Expo bare workflow project to Expo SDK 43 and am using the MediaLibrary expo package to save files. The problem is that I use MediaLibrary.requestPermissionsAsync and it never asks the user to grant the WRITE_INTERNAL_STORAGE and READ_INTERNAL_STORAGE. Upon further inspection, it looks like it automatically grants these permissions. How do I make it stop doing that?

What I have tried: I have made sure that my Android Manifest has both <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE">and <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE". I have uninstalled the app from my device and reinstalled but still, the permissions are granted. At this point, I am lost on how to fix this because any similar issue I find online only shows a fix for managed workflow Expo projects.

Here are the versions of everything I am using: Expo: 43.0.3, Expo MediaLibrary: 13.0.3, Pixel 3a running Android 12, React-Native: 0.64.3

If more information is needed let me know.

Edit: I also tested it on a Samsung Device running Android version 9 and it is still automatically granting the WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions.

1 Answers

I figured out if I load the app on my device by using npx react-native run-android it would automatically grant the permissions for READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE without asking the user to grant the permission. If instead I went into my android folder for my project and built an APK using ./gradlew assembleRelease (or debug) and sideload the APK onto my device it will ask the user to grant the needed permissions. Doing this also fixed an issue I was having that caused icons I'd imported from @expo/vector-icons to not be bundled with the release version of my app.

Related