Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

The all-files access permission never gets granted

ErrorUnable to request MANAGE_EXTERNAL_STORAGE

Short answer

MANAGE_EXTERNAL_STORAGE is a special app access, not a normal runtime permission. Declare it in the manifest, send the user to the all-files settings page with the documented intent, and check Environment.isExternalStorageManager(). Even then, other apps' folders under Android/data stay closed.

  • Applies to Android 11 to 16, Android Studio, Kotlin
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask the system whether your app has the access, and look at the manifest for the declaration.

    adb shell appops get PACKAGE_NAME MANAGE_EXTERNAL_STORAGE
    grep -n "MANAGE_EXTERNAL_STORAGE" app/src/main/AndroidManifest.xml
  2. 2Match what you see, then jump to its fix

    1. 1No dialog appears, or the result is always denied, after requestPermissionsIt was requested like a runtime permissionFix
    2. 2The grep from the first step prints nothingThe permission is not declared in the manifestFix
    3. 3isExternalStorageManager() is true, yet writes to Android/data failThe access is granted but the folder is still closedFix
    4. 4Writes to shared storage fail although the old storage permission is grantedThe app only holds WRITE_EXTERNAL_STORAGE and targets Android 11 or higherFix
    5. 5Play Console rejects the release, or Android Studio shows a lint warning on the permissionTesting before Google Play approves the use caseFix

What does the error look like?

  • Unable to request MANAGE_EXTERNAL_STORAGE
  • Environment.isExternalStorageManager() returns false

Cause 1 of 5

It was requested like a runtime permission

1Check

The doc says to direct users to a system settings page where they enable Allow access to manage all files for your app. A permission dialog does not do that.

grep -rn "requestPermissions\|ActivityResultContracts.RequestPermission" app/src/main

2Fix

Launch the settings intent action named in the docs, and test the result when the user returns.

val intent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
startActivity(intent)

// in onResume
val granted = Environment.isExternalStorageManager()

3Verify

Switch the option on in settings, return to the app, and the check returns true.

adb shell appops get PACKAGE_NAME MANAGE_EXTERNAL_STORAGE

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 5

The permission is not declared in the manifest

1Check

Step one of the documented flow is declaring MANAGE_EXTERNAL_STORAGE in the manifest.

grep -n "uses-permission" app/src/main/AndroidManifest.xml

2Fix

Add the declaration, rebuild and reinstall.

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

3Verify

Install the new build and open the all-files list in settings to see the app.

./gradlew :app:installDebug

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 5

The access is granted but the folder is still closed

1Check

The permission gives write access to internal storage directories except /Android/data/ and /sdcard/Android and most subdirectories, and other apps' app-specific folders stay inaccessible.

adb shell ls /sdcard/Android/data

2Fix

Use a folder outside those paths, or the Storage Access Framework or MediaStore for the files your app really needs.

// write under Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)

3Verify

Write a small file and read it back.

adb shell ls /sdcard/Documents

Confirmed by developer.android.com

Did this fix it?

Cause 4 of 5

The app only holds WRITE_EXTERNAL_STORAGE and targets Android 11 or higher

1Check

When an app targets Android 11, WRITE_EXTERNAL_STORAGE no longer provides any additional access, and READ_EXTERNAL_STORAGE all-files access is read-only.

grep -n "targetSdk" app/build.gradle*

2Fix

Use MediaStore or the Storage Access Framework for ordinary files, or request all-files access only if the app's core use needs it.

// contribute to MediaStore.Downloads without any storage permission on Android 10+

3Verify

Write a test file through MediaStore and read it back.

adb shell ls /sdcard/Download

Confirmed by developer.android.com

Did this fix it?

Cause 5 of 5

Testing before Google Play approves the use case

1Check

For apps targeting Android 11 or higher, Google Play evaluates apps that request this permission, and Android Studio shows a lint warning that reminds you.

./gradlew :app:lintDebug

2Fix

Request it only when the privacy-friendly APIs cannot do the job, and the use is core to the app. For local tests, grant it with adb.

adb shell appops set --uid PACKAGE_NAME MANAGE_EXTERNAL_STORAGE allow

3Verify

The appops query shows allow.

adb shell appops get PACKAGE_NAME MANAGE_EXTERNAL_STORAGE

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Prefer MediaStore and the Storage Access Framework, and keep all-files access for file managers, backup and similar core uses.
  • Re-check isExternalStorageManager() each time the app returns from settings.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.