How to Fix Exception ‘open failed: EACCES (Permission denied)’ on Android

  • Post last modified:May 9, 2021
  • Reading time:3 mins read

Today, I was working with my old program, which I had made in December 2020. Due to some odd reason, I delayed my app development process.

An application was working a few months back suddenly the app gets crashed with the error Exception ‘open failed: EACCES (Permission denied)’

The application workflow was pretty simple. When the user clicks on Share Button programmatically, the application will take a screenshot and use the explicit intent user as options to send screenshots using any applications that support Image share.

I took a paused for a moment and started thinking, What wrong suddenly happen to the project? If you read the error, it says something is wrong with the permissions.

Instantly I checked with the permissions code found everything good when I open Android Manifest found the culprit “WRITE_EXTERNAL_STORAGE no longer provides write access when targeting Android 10+.”


The problem starts getting clear. I open build.gradle and checked target version is changed to API 29 (Android 10) somehow.


As usual, I did research and found that the Application target for SDK 29 uses scoped storage for the default.

If you are thinking, What is Scoped Storage? I’ll clarify to you that Scoped Storage sets a limit to the access file.

For example, If my XYZ application is stored in a specific directory location, wants to upload photos from any other Directory other than the application directory, I’ll not be allowed to access the file according to the new google policy.

So we got the problem; tell me, Gagan, how to resolve this? You can use MediaStore or simply use Legacy Storage policy.

How to resolve above using LegacyStorage?

We need to pass the single line of code, which will turn off the flag for Android 10 devices, and you will be allowed to use LegacyStorage.

Go to the project pane and Click on AndroidManifest and add the highlighted code inside <application>.

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

Changes should like this below Sample Image.

Add requestLegacyExternalStorage
Add requestLegacyExternalStorage

Once you add the requestLegacyExternalStorage = “true” under the <application> tag Run the application and your application functions will start working.

How to fix exposed beyond app through ClipData.Item.getUri

Wrap up

That’s it to resolve Exception ‘open failed: EACCES (Permission denied)’. If you are still facing any issues while following this guide, please let us know in a comment section.

For your ease, we have uploaded a sample project to the GitHub repository. To clone the repository click on this link.

What are your thoughts about this article?

Like what you read? Please share it with others.
  • 2

This Post Has 10 Comments

  1. Proyo

    this will not work in android 11

    1. Gagan Mishra

      you are right

      1. Prasanth

        What is the solution for it in Android 11?

        1. Gagan Mishra

          We will drop the article very soon.

    2. coder

      what to do for android 11

      1. Smh

        android manifest in app

        <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>

        you need to add

  2. Ruud

    Thank you !. Google is insane with every day new rules.

    1. Denis

      Hello everyone. thanks for the solution.

      But in my case, that insertion does not work.
      I am now developing a mobile app with react native.
      The trouble is occured when I try to put the file on firebase storage.
      Of course, I inserted that line of code to my androidmanifest.xml file.

      And this is the bulidscript
      buildscript {
          ext {
              buildToolsVersion = “29.0.3”
              minSdkVersion = 21
              compileSdkVersion = 29
              targetSdkVersion = 29
              ndkVersion = “20.1.5948944”
              playServicesVersion = “17.0.0”
              androidMapsUtilsVersion = “2.2.3”

      And this is the uploading script
      // uploads file
          const pngRef = storage().ref(avatar/upload.png);
          await pngRef.putFile(fileUri);
          const url = await storage()
      Is there any solution with this? Is this the firebase error?
      I will be happy if anyone helps me.

  3. Vinay

    I have tried to add the below line in application tag

    But I am getting the below error while building the app

    error: attribute android:requestLegacyExternalStorage not found.

    1. Gagan Mishra

      Let me see

Leave a Reply