react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

Android 11 new policy "MANAGE_EXTERNAL_STORAGE"

Open cerdonmez opened this issue 4 years ago • 23 comments
trafficstars

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.

cerdonmez avatar Apr 19 '21 11:04 cerdonmez

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.

imranMnts avatar Apr 29 '21 09:04 imranMnts

there's an older issue also about this, but no one seems to be helping #926

tolgaerdonmez avatar May 03 '21 11:05 tolgaerdonmez

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

nikoloz110 avatar May 03 '21 15:05 nikoloz110

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?

JowelTisso avatar May 04 '21 12:05 JowelTisso

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.

guofoo avatar May 07 '21 09:05 guofoo

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?

gabrielporcher avatar May 20 '21 14:05 gabrielporcher

Have any solution?

thuynt99 avatar Jul 06 '21 09:07 thuynt99

Does anyone have solution? I think it is very important issue for android.

jihokim2 avatar Jul 21 '21 08:07 jihokim2

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.

gabrielporcher avatar Jul 23 '21 14:07 gabrielporcher

Any update?

jihokim2 avatar Aug 10 '21 00:08 jihokim2

Anything new here? has anyone found a solution?

malgorzatatanska avatar Aug 27 '21 10:08 malgorzatatanska

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(); }

tusharaddeveloper avatar Sep 04 '21 09:09 tusharaddeveloper

You need to add additional permission called MANAGE_EXTERNAL_STORAGE, you can see in this post

https://stackoverflow.com/a/69820147/10851423

iqbalprasas avatar Nov 03 '21 05:11 iqbalprasas

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?

naudej avatar Nov 04 '21 12:11 naudej

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.

vindeolal avatar Nov 11 '21 11:11 vindeolal

Any update ?

brunofariasd avatar Jan 08 '22 19:01 brunofariasd

#1053

iqbalprasas avatar Mar 23 '22 08:03 iqbalprasas

Any work around about this issue. I am trying to access "Manage all file access" but cant.

Hassan-jr avatar Aug 01 '22 13:08 Hassan-jr

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 avatar Aug 01 '22 14:08 guofoo

@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?

alejandrosazo avatar Feb 24 '23 14:02 alejandrosazo

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

Hassan-jr avatar Feb 24 '23 14:02 Hassan-jr