The all-files access permission never gets granted
Unable to request MANAGE_EXTERNAL_STORAGEShort 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.
Fix it fast
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.xml2Match what you see, then jump to its fix
- 1
No dialog appears, or the result is always denied, after requestPermissionsIt was requested like a runtime permissionFix - 2
The grep from the first step prints nothingThe permission is not declared in the manifestFix - 3
isExternalStorageManager() is true, yet writes to Android/data failThe access is granted but the folder is still closedFix - 4
Writes to shared storage fail although the old storage permission is grantedThe app only holds WRITE_EXTERNAL_STORAGE and targets Android 11 or higherFix - 5
Play Console rejects the release, or Android Studio shows a lint warning on the permissionTesting before Google Play approves the use caseFix
- 1
What does the error look like?
Unable to request MANAGE_EXTERNAL_STORAGEEnvironment.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/main2Fix
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_STORAGEConfirmed by developer.android.com
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.xml2Fix
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:installDebugConfirmed by developer.android.com
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/data2Fix
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/DocumentsConfirmed by developer.android.com
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/DownloadConfirmed by developer.android.com
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:lintDebug2Fix
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 allow3Verify
The appops query shows allow.
adb shell appops get PACKAGE_NAME MANAGE_EXTERNAL_STORAGEConfirmed by developer.android.com
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:
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Nuclear Home VideoA video-streaming Android app built from scratch, engineered for smooth playback.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
Android build fails because a product flavor has no flavor dimension
The flavor 'flavor_name' is not assigned to a flavor dimension.
Android Gradle plugin refuses to build when a product flavor is not assigned to a flavor dimension.
2 causes, each with a fixMobile apps
AGP 9 marks the android block as deprecated or fails on BaseExtension
java.lang.ClassCastException: class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.BaseExtension
AGP 9.0 uses only the new public DSL interfaces.
3 causes, each with a fixMobile apps
Android build fails because two libraries ship the same META-INF file
More than one file was found with OS independent path
Two dependencies put a file at the same path inside the APK and the plugin will not guess which one wins.
3 causes, each with a fixMobile apps
The editor cannot find R, so every R.string and R.id turns red
Unresolved reference: R
R is a class that the build generates from your res folder, in the package named by the module's namespace.
4 causes, each with a fixMobile apps
Android Studio says it could not identify the launch activity when you press Run
Run > Edit Configurations > Launch Options is set to Nothing or to a class that no longer exists
Android Studio launches the activity marked with a MAIN action and a LAUNCHER category in the merged manifest.
3 causes, each with a fixMobile apps
FirebaseInstanceIdService and FirebaseInstanceId.getToken() no longer work
Deprecation warning on FirebaseInstanceId.getInstance().getToken()
Move token handling into a class that extends FirebaseMessagingService and override onNewToken, which runs when a token is first created and whenever it changes.
2 causes, each with a fix