react-native-fs
react-native-fs copied to clipboard
Android 11 new policy "MANAGE_EXTERNAL_STORAGE"
Google App Store send me a message as below. What should we do about it?
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.
Do we have any update on that, please?
Currently, react-native-fs is using deprecated android permission which will be rejected by Google in the future.
there's an older issue also about this, but no one seems to be helping #926
from what I have researched as long as apps target sdk is set to 29 or less, we should be good, but nonetheless, this issue needs to be addressed sooner or later
I guess using the Storage Access Framework or Media Store API will do the work... which is tricky to implement...? and I also need help in?
I looked through a few pages of opens issues to tie back the related issues caused by the upgraded Scoped Storage changes in Android 11. If you see other, older ones, please feel free to reference them back to this single issue so it's easier for everyone to track.
While we are targeting Sdk29, this lib is working well. But, after august 2021, we will have to target sdk 30 to be accepted in google play store.
I tried to implement the new Scopped method, but seems that react-native-fs doesnt support it (withtout the android:requestLegacyExternalStorage="true").
There is something that we can do, to accept tagertSdk30? Or should this lib be updated?
Have any solution?
Does anyone have solution? I think it is very important issue for android.
I dont think that we have any solution yet. But sure, it its VERY importante, because new apps will cannot use this lib anymore next week.
Any update?
Anything new here? has anyone found a solution?
Use
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
instead of MANAGE_STORAGE
Use below code to save file No need allow any storage permission in > Q for the same:
if (SDK_INT >= Build.VERSION_CODES.Q) { ContentResolver resolver = context.getContentResolver(); ContentValues contentValues = new ContentValues(); contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, fileName); contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "video/mp4"); contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, dir); Uri videoUri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, contentValues); OutputStream output = resolver.openOutputStream(videoUri); output.write(data, 0, count); output.close(); }
You need to add additional permission called MANAGE_EXTERNAL_STORAGE, you can see in this post
Hi, any updates how to fix this? We need to target Android 11 in order to deploy an update to Play store, is there any work around for targetSdkVersion = 30?
Hi, any workaround or updates on this? We are using targetSdkVersion 30 and are not able to copy or move files from an external location.
Any update ?
Any work around about this issue. I am trying to access "Manage all file access" but cant.
After not able to proceed, I've given up and moved on to expo-file-manager package to be able to do I what I needed to do. However, that'll introduce a whole other can of worms to waddle through. Things don't come easy.
@guofoo did you switch to the expo-file-manager library?? Is it better than expo-file-system? Or was a solution found with this library?
I solved this issue for all React Native developers. I published an NPM package called react-native-manage-external-storage that you can use it to access all files in an android phone.
Here is a link checkout https://www.npmjs.com/package/react-native-manage-external-storage