Open TheWirv opened 3 years ago
I got similar issue, I tried to write a file to RNFetchBlob.fs.dirs.DownloadDir
but it always returns Permisson Denied
. After digging a bit more into it turns out Android 10 introduce a new storage paradigm called scoped storage. So far the only workaround that I found is to add
<application android:requestLegacyExternalStorage="true" ... >
...
</application>
to your AndroidManifest.xml
but this is only temporary. It would be amazing if rn-fetch-blob
could support scoped storage 🙇 .
Got the same Problem, this workaround fixed it for me. Would be great if this will be part of rn-fetch-blob in an next update.
same here
I found a way to get around it: https://github.com/idealistspace/react-native-android-file-util Use this instead, to save a file somewhere on the phone the other fix doesn't work on Andriod 11
@2mt-hillen "fix doesn't work on Andriod 11" -> you mean already now or its only when app is targeting sdk level 30?
for us it threw an error on android 11, with the code in the other repo it worked fine
and we're targeting sdk 29
According to the android 11 release notes, requestLegacyExternalStorage
should continue to work on Android 11 devices if we are targetting API level 29.
https://developer.android.com/about/versions/11/privacy/storage
it's not working on Android 11 devices at all anymore
it's not working on Android 11 devices at all anymore
@Tino-F are you sure? did you try requestLegacyExternalStorage as supposed before?
it's not working on Android 11 devices at all anymore
@Tino-F are you sure? did you try requestLegacyExternalStorage as supposed before?
Yeah it looks like Google Thanosd the requestLegacyExternalStorage option. Someone explained it pretty well in the stack overflow link below.
it's not working on Android 11 devices at all anymore
@Tino-F are you sure? did you try requestLegacyExternalStorage as supposed before?
Yeah it looks like Google Thanosd the requestLegacyExternalStorage option. Someone explained it pretty well in the stack overflow link below.
it depends on targetSdkVersion. It should still work if you are targeting API 29
it's not working on Android 11 devices at all anymore
@Tino-F are you sure? did you try requestLegacyExternalStorage as supposed before?
Yeah it looks like Google Thanosd the requestLegacyExternalStorage option. Someone explained it pretty well in the stack overflow link below. https://stackoverflow.com/questions/63364476/requestlegacyexternalstorage-is-not-working-in-android-11-api-30
it depends on targetSdkVersion. It should still work if you are targeting API 29
I can confirm, my app is targeting API 29 and requestLegacyExternalStorage=true
is still applying on my Samsung S10+ with Android 11.
Google won't allow android:requestLegacyExternalStorage
after May 5. This needs to be solved soon
I think is not something about this library, we migrate to API 30, we kept android:requestLegacyExternalStorage=true and add
The only thing we have to change in our app is to avoid creating folders because API 30 external storage doesn't allow that. The app is saving to disk without any problem, the only problem we have is that it seems API 30 doesn't allow to rewrite with the same name of the file, any help will be appreciated.
if (Platform.OS === 'android')
path = `${RNFetchBlob.fs.dirs.DCIMDir}/videoaux.mp4`;
else path = `${RNFetchBlob.fs.dirs.DocumentDir}/sqso/videoaux.mp4`;
PS: We didn't publish to the console yet, so we are not 100% sure that "after May 5" will be solved.
Matt
I got the same message @anjalsaneen linked when trying to update an app. Does anyone have some extra info on this? It seems I was able to upload anyway, but I'm not sure what are the consequences exactly if there's any.
The message says "You must let us know why" - and yet, I didn't see where / how I could let them know why.
It also seems like I could add MANAGE_EXTERNAL_STORAGE
permission and complete the declaration in the play console as an alternative.
I'm currently targeting API 29, do I need to do any additional action - or is it time to move on to an actual maintained library?
@Dror-Bar This Google Play policy refers specifically to apps that target API level 30 and need the MANAGE_EXTERNAL_STORAGE permission (All Files Access). If you don’t use or plan to use this permission, this policy shouldn’t affect you. If you are currently targeting API level 29 and want to use this permission when you update to target API level 30, you will need to comply with this policy. The last date to update App to target Sdk 30 is August 2021. have time till August
This is my build.gradle ext { buildToolsVersion = "29.0.3" minSdkVersion = 23 compileSdkVersion = 30 targetSdkVersion = 29 supportLibVersion = "29.0.0" }
But i still get error.
LOG [Error: Permission denied]
When i try
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
this.setState({spinner: true});
RNFetchBlob.fs.writeFile(path, base64string, 'base64')
.then((res) => {this.setState({spinner: false});})
.catch(error => console.log(error));
}
What should i do now.
Secondly is it mandatory to target SDK 30 After August-2021 if so what all should i do
I can currently access the download directory on all Android versions (including 11) with this setup:
build.gradle:
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
...
<application
...
android:requestLegacyExternalStorage="true">
I DON'T have the permission MANAGE_EXTERNAL_STORAGE
.
I can successfully run RNFetchBlob.fs.exists
, RNFetchBlob.fs.writeFile
and RNFetchBlob.fs.readFile
over the Downloads directory (RNFetchBlob.fs.dirs.DownloadDir
), however I don't understand WHY, since the documentation is pretty clear that the MANAGE_EXTERNAL_STORAGE
permission is required in order to read and write to the Download
directory.
This is what the permissions looks like in the settings:
Is this ok or will it break at some point or get rejected when submitted in the play store?
I can confirm if we add requestLegacyExternalStorage to the application tag then we can read write normally. And yes I wonder if Is this ok or will it break at some point or get rejected when submitted in the play store?
what happen with this bug in android 11?
Is there any progress/solution for this? I just got the same issue on Android 10
you can use https://github.com/RonRadtke/react-native-blob-util that is updated with the implementation of Android Scoped Storage.
Hi, I am trying to save some base64 data to file, but somehow I can't get it to work. Everytime I am trying to access external storage (
/storage/emulated/0
), I getPermission denied
fromcreateFile()
orwriteFile()
—I have tried both already. I am also asking for permission beforehand, as you can see in my code snippet. I also added the stuff toAndroidManifest.xml
.The only location that doesn't raise the
Permission denied
exception isRNFetchBlob.fs.dirs.DocumentDir
, but that is/data/user/0/{bundleId}/files
and I am not sure, what that's translating to. This exact path does not exist on my phone, but I suspect it's{Internal storage}/Android/data/{bundleId}/files
. Even so, after runningcreateFile()
/writeFile()
"successfully" there's no file at that location.Am I missing something crucial here? I'm really out of my depth on this one. I hope someone can help me.
the version of installed library and RN project. react-native: v0.63.3 rn-fetch-blob: v0.12.0 Android 10 (Samsung Galaxy S10; One UI v2.5)
a sample code snippet/repository is very helpful to spotting the problem.
If you need any additional info, just let me know.