Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENOENT: open failed: EACCES (Permission denied), open '/storage/emulated/0/Download/ #941

Closed
ShivamJoker opened this issue Oct 13, 2020 · 22 comments

Comments

@ShivamJoker
Copy link

I encountered this issue so I am writing this just to tell everyone how to fix this permission issue in android

I have added permissions in manifest file

....
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> // worked without this also
...
<application ...
android:requestLegacyExternalStorage="true" // this is needed
....
>

Also don't forget to ask for permission

try {
    const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
      {
        title: "Cool Photo App Camera Permission",
        message:
          "Your app needs permission.",
        buttonNeutral: "Ask Me Later",
        buttonNegative: "Cancel",
        buttonPositive: "OK"
      }
    );
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
      return true;
    } else {
      console.log("Camera permission denied");
      return false;
    }
  } catch (err) {
    console.warn(err);
    return false;
  }
@wmonecke
Copy link

Stumbled upon this right now!

@vikil143
Copy link

vikil143 commented Jan 29, 2021

I did both add permission and android:requestLegacyExternalStorage in the manifest file also ask for permission also how this could be solved

@vikil143
Copy link

It solved when restarted the app

@nemishzalavadiya
Copy link

nemishzalavadiya commented Mar 21, 2021

thanks worked for me as well. just do not forget to rebuild the app.

@rajan-keypress
Copy link

<application ...
android:requestLegacyExternalStorage="true" // this is needed
....

work for me

@sam9010
Copy link

sam9010 commented May 12, 2021

<application ...
android:requestLegacyExternalStorage="true" // this is needed
....

work for me

android\app\build\intermediates\merged_manifests\debug\arm64-v8a\AndroidManifest.xml:27: AAPT: error: attribute android:requestLegacyExternalStorage not found.

has error

@lukas-bunat
Copy link

For me also adding the:

<application ...
android:requestLegacyExternalStorage="true" // this is needed
....

solved the issue for me. Application rebuild is needed!

@gitrthanki1
Copy link

<application ...
android:requestLegacyExternalStorage="true"
....
I make this change but still issue is there it gives me error like ENOENT: open failed: EACCES (Permission denied), open '/storage/emulated/0/Download/config.txt'

@SohelKabir
Copy link

android:requestLegacyExternalStorage="true" not working api level 30

@conkyliu
Copy link

android:requestLegacyExternalStorage="true" not working api level 31
PermissionsAndroid=== {android.permission.WRITE_EXTERNAL_STORAGE: 'granted', android.permission.READ_EXTERNAL_STORAGE: 'granted'}

@mintheinwin
Copy link

<application ...
android:requestLegacyExternalStorage="true"
....
I make this change but still issue is there it gives me error like ENOENT: open failed: EACCES (Permission denied), open '/storage/emulated/0/Download/config.xlsx'

@sathishkumarm1701
Copy link

<application ... android:requestLegacyExternalStorage="true" .... I make this change but still issue is there it gives me error like ENOENT: open failed: EACCES (Permission denied), open '/storage/emulated/0/Download/config.xlsx'

Have you fixed the error for the permission denied?
if you fixed tell me how to fix the error and what was the changes are

@vikil143
Copy link

<application ...
android:requestLegacyExternalStorage="true"

Add this and rebuild the app

@jack828
Copy link

jack828 commented Sep 21, 2023

For expo you can use this plugin i wrote to add the tag to <application> in a managed workflow.

app.json

"plugins": ["./expo/with-legacy-storage.js"]

./expo/with-legacy-storage.js

const { withAndroidManifest } = require('@expo/config-plugins')

module.exports = (config) => {
	const modifyAndroidManifest = (manifest) => {
		const applicationTag = manifest['application'][0]
		applicationTag.$['android:requestLegacyExternalStorage'] = 'true'
		manifest['application'][0] = applicationTag
		return manifest
	}
	return withAndroidManifest(config, async (config) => {
		config.modResults.manifest = modifyAndroidManifest(
			config.modResults.manifest,
		)

		return config
	})
}

@luckyloafer
Copy link

i made all the changes..still the same error

@conkyliu
Copy link

conkyliu commented Dec 9, 2023 via email

@Pragnesh-Dharajiya
Copy link

Pragnesh-Dharajiya commented Dec 27, 2023

<application ...
android:requestLegacyExternalStorage="true">

work for me thanks

@conkyliu
Copy link

conkyliu commented Dec 27, 2023 via email

@adityasid
Copy link

I encountered this issue so I am writing this just to tell everyone how to fix this permission issue in android

I have added permissions in manifest file

....
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> // worked without this also
...
<application ...
android:requestLegacyExternalStorage="true" // this is needed
....
>

Also don't forget to ask for permission

try {
    const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
      {
        title: "Cool Photo App Camera Permission",
        message:
          "Your app needs permission.",
        buttonNeutral: "Ask Me Later",
        buttonNegative: "Cancel",
        buttonPositive: "OK"
      }
    );
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
      return true;
    } else {
      console.log("Camera permission denied");
      return false;
    }
  } catch (err) {
    console.warn(err);
    return false;
  }

Thanks
Worked for me, Don't forget to rebuild the app

@conkyliu
Copy link

conkyliu commented Mar 28, 2024 via email

@vijayanand-006
Copy link

Hii EveryOne! , Can someone help me

I'm facing issue on after getting download the pdf it not open properly , it show that cannot display pdf.

@conkyliu
Copy link

conkyliu commented Sep 30, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests