how to use expo-image-picker with android 11 scoped storage?

2.4k views Asked by At

I was using expo-image-picker in my expo managed react native app. It was working fine. I just needed to use the camera to take new photo and to pick photo from gallery for my app. For these I was using the following APIs

ImagePicker.requestMediaLibraryPermissionsAsync()
ImagePicker.requestCameraPermissionsAsync()

ImagePicker.launchImageLibraryAsync()
ImagePicker.launchCameraAsync()

for android, my permissions array in app.json file was following

"permissions": [
        "CAMERA",
        "CAMERA_ROLL",
        "READ_EXTERNAL_STORAGE",
        "WRITE_EXTERNAL_STORAGE",
        "LOCATION"
      ]

Now google sent me this email

We've detected that your app contains the requestLegacyExternalStorage flag in the manifest file of 1 or more of your app bundles or APKs.

Developers with apps on devices running Android 11+ must use Scoped Storage to give users better access control over their device storage. To release your app on Android 11 or newer after May 5th, you must either:

Update your app to use more privacy friendly best practices, such as the Storage Access Framework or Media Store API Update your app to declare the All files access (MANAGE_EXTERNAL_STORAGE) permission in the manifest file, and complete the All files access permission declaration in Play Console from May 5th Remove the All files access permission from your app entirely For apps targeting Android 11, the requestLegacyExternalStorage flag will be ignored. You must use the All files access permission to retain broad access.

Apps requesting access to the All files access permission without a permitted use will be removed from Google Play, and you won't be able to publish updates.

Can anybody help me how to fix this? Do i need to change anything in my Image picker api? Or Do i need to add / remove something from my permissions array? Please help me ...Please...

1

There are 1 answers

0
Habibur Rahman On BEST ANSWER

Got the solution. Actually there's no problem with my code. It is google who made me confused. Here's the detail https://github.com/expo/expo/issues/12603#issuecomment-827600227