APK Downloader
·16 min read

Sideloaded App Fails to Share Files or Open Attachments: A Layer-by-Layer Guide to FileProvider and content:// URI Grants

You sideload an APK and everything works - until you tap Share and the app crashes, the receiving app says 'file not found', opening an attachment throws 'Permission Denial', thumbnails come through blank, or the share sheet shows no target apps at all. This is rarely a broken build. Since Android 7.0, file:// URIs cannot cross app boundaries; FileProvider configuration, temporary URI permission grants, authority collisions, scoped storage and package visibility each break a different link in the chain. This guide gives mechanism tables, runnable adb / aapt / curl commands, a nine-step diagnostic path, an error lookup table, version differences, an FAQ, and links to related guides.

FileProvidercontent URIURI grantsadbtroubleshooting

You install an APK from outside the Play Store. The app itself works fine. Then you try to hand a file to another app and everything falls apart: tapping Share crashes instantly; picking a messenger or mail app produces "could not retrieve file" or "file does not exist"; opening an attachment in a document viewer says "cannot access this file"; the preview thumbnail arrives blank; or the share sheet contains no target apps at all.

The natural conclusion is "this is a stripped or pirated build, I'll reinstall." Reinstalling almost never helps, because these failures live in Android's cross-app file handoff mechanism, not in missing app features. Sideloading raises the odds because four variables stack up at once: a different install source changes signing and provider authorities, repackaged or "lite" builds lose their FileProvider configuration, old-targetSdk apps still emit the file:// URIs banned since Android 7.0, and scoped storage (Android 10+) plus package visibility (Android 11+) add their own failure modes on top.

This guide walks through five layers - URI scheme, FileProvider configuration, temporary grants, authority uniqueness, and storage/visibility - with a check you can run at each one, then a nine-step diagnostic path.

1. Six Different "Share Failed" Symptoms

Different symptoms point to different layers. Do not start by reinstalling.

SymptomMost likely broken layerFirst check
Instant crash on Share, logcat shows FileUriExposedExceptionURI schemeadb logcat for the exception stack
Receiving app says "file not found / could not retrieve"Temporary URI grantCheck for FLAG_GRANT_READ_URI_PERMISSION on the Intent
Opening attachment throws "cannot access / Permission Denial"Receiver's read pathadb logcat for SecurityException
Shared image or thumbnail is blankClipData and metadataVerify setClipData was also called
Share sheet lists no target appsPackage visibility / Intent resolutiondumpsys package for <queries>
Installing a second similar app fails outrightAuthority collisionLook for INSTALL_FAILED_CONFLICTING_PROVIDER

2. Layer One: Since Android 7.0, file:// Cannot Cross Apps

This is the root of most cases. Before Android 7.0 (API 24), apps commonly shared a file by putting a raw path into an Intent, such as file:///storage/emulated/0/Download/a.pdf. Nougat enabled a StrictMode check on Intents exposed to other apps: if Intent.getData() holds a file:// URI, the system throws android.os.FileUriExposedException, and an app that does not handle it crashes on the spot.

The reasoning is straightforward. Handing another app a real filesystem path means handing over the ability to read that private directory along with the path; the system cannot scope such access to one component, cannot expire it, and cannot revoke it. So Android moved to content://<authority>/<path>: the providing app's own ContentProvider brokers the read, and the system issues the receiver a short-lived, revocable read or write grant.

URI schemeExampleApplies toTemporary grant?Sideload verdict
file://file:///sdcard/Download/a.pdfAPI ≤ 23No - path IS the permissionOld-targetSdk builds still emit it; crashes on API 24+
content:// (FileProvider)content://com.xxx.fileprovider/external/a.pdfAPI ≥ 24, recommendedYes, FLAG_GRANT_*Standard path; config often stripped by repackagers
content:// (MediaStore)content://media/external/file/12345API ≥ 29 mediaYes, scoped grantCorrect route for shared media under scoped storage
content:// (SAF / DocumentsProvider)content://com.android.externalstorage.documents/...API ≥ 19Yes, can be persistableWhat ACTION_OPEN_DOCUMENT returns

How to tell: look at the URI prefix in the crash log. If it contains file:// and the device is API 24+, layer one is your answer.

adb logcat -v time | grep -iE "FileUriExposedException|exposed beyond app|file:///|StrictMode"

One warning about "fixes" you will find online: calling StrictMode.disableDeathOnFileUriExposure() or relaxing VmPolicy in Application.onCreate() only suppresses the crash. It does not make the receiver able to read the file, and under scoped storage on Android 10+ it fails anyway. Do not treat it as a solution.

3. Layer Two: The Three Things FileProvider Needs Simultaneously

A content:// URI does not appear by magic. androidx.core.content.FileProvider (or android.support.v4.content.FileProvider in older builds) maps a real path to a virtual URI. Three pieces must all be present:

  1. A <provider> declaration in the Manifest with a unique authority, android:exported="false" and android:grantUriPermissions="true";
  2. A <meta-data> entry pointing at res/xml/file_paths.xml, which declares which root directories may be mapped;
  3. Code that calls FileProvider.getUriForFile(context, authority, file) rather than hand-building the URI string.

A standard declaration looks like this:

<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="${applicationId}.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
</provider>

Each tag in file_paths.xml maps one class of root directory. Getting this wrong produces the classic Failed to find configured root that contains /...:

Path tagDirectoryTypical use
<files-path>Context.getFilesDir()App-private files
<cache-path>Context.getCacheDir()Temporary files staged for sharing
<external-path>Environment.getExternalStorageDirectory()Legacy shared root
<external-files-path>Context.getExternalFilesDir()App-external private dir, no storage permission needed
<external-cache-path>Context.getExternalCacheDir()External cache
<external-media-path>Context.getExternalMediaDirs()Media dirs, API 21+
<root-path>Device root /Avoid - exposes the whole device through the URI

This is exactly where sideloaded builds go wrong. "Lite", "ad-free" or "dual-account" repackages frequently delete the res/xml/ config, or change applicationId without updating the authority, so getUriForFile() throws IllegalArgumentException. No setting can restore a missing config - you need the official full build.

Verify with aapt/apktool on a computer (no root needed):

aapt dump xmltree app.apk AndroidManifest.xml | grep -iE "provider|authorities|grantUriPermissions|FILE_PROVIDER_PATHS|exported"
unzip -l app.apk | grep -iE "file_paths|xml/"
aapt dump badging app.apk | grep -E "package:|targetSdkVersion:"

If aapt shows no provider node at all, the build never configured FileProvider. If authorities is a hardcoded literal instead of ${applicationId}.fileprovider, a renamed "clone" build will almost certainly collide with the original (see layer four).

4. Layer Three: How Temporary URI Grants Work and When They Expire

Generating a content:// URI does not mean the receiver can read it. By default, other apps have no permission on your provider; the sender must grant it explicitly. This is the number one cause of "shared fine, but the other app says file not found."

Grant methodHowScopeCommon mistake
Intent flagintent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)Travels with that Intent to the target ActivityAdded for ACTION_SEND, but a second URI in setData/ClipData is left ungranted
Explicit grantcontext.grantUriPermission("com.target.pkg", uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)Named package, until revokeUriPermission or rebootUseless when the target package is unknown
ClipDataintent.setClipData(ClipData.newUri(cr, "file", uri))Delivered alongside the IntentMandatory for multi-file / thumbnail shares on Android 5.0+; omit it and the grant is lost
Persistable granttakePersistableUriPermission(uri, flags) after ACTION_OPEN_DOCUMENTSurvives rebootDocumentsProvider only; FileProvider does not support it

Details that are easy to miss:

  • Grants are one-shot. A grant attached to an Intent is bound to the receiving Activity's task stack. If the receiver process is killed or the task is destroyed, the grant is gone. "It opened once, then reopening from history fails" is expected behaviour, not a bug.
  • The grant must cover the field that actually carries the URI. Many apps put the URI in Intent.setData() and a second copy in EXTRA_STREAM. Granting one leaves the other unreadable.
  • Multi-file shares need ClipData, plus read and/or write flags as required. Granting read but letting the receiver write back produces a SecurityException.
  • The receiver must read via `ContentResolver`. Calling new File(uri.getPath()) on a content:// URI can never work, and is a frequent cause of "open attachment in another app" failures.

You can simulate a properly granted VIEW from adb to separate "sender forgot the grant" from "receiver reads it wrong":

adb shell am start -a android.intent.action.VIEW \
  -d "content://com.example.fileprovider/external/a.pdf" \
  -t "application/pdf" \
  -f 0x00000001

-f 0x00000001 is FLAG_GRANT_READ_URI_PERMISSION. If this opens the file but the in-app Share does not, the bug is in the sender's Intent assembly. If it still says Permission Denial, look at the receiver's read API.

adb logcat -v time | grep -iE "Permission Denial|grantUriPermission|SecurityException|openInputStream|Failed to find configured root"

5. Layer Four: Authority Collisions - A Sideload-Only Install Failure

ContentProvider authorities must be unique device-wide. At boot, PackageManagerService registers every provider from every installed app; if two apps declare the same authority, the second install is rejected:

Failure [INSTALL_FAILED_CONFLICTING_PROVIDER: ... Can't install because provider name ... is already used by ...]

Sideloading hits this because "clone / dual / modded" builds often change the package name and signature but leave the authority as a hardcoded literal such as com.original.app.fileprovider, instead of deriving it from ${applicationId}. The original and the mod then collide. A subtler variant: the mod is installed first and squats on the authority, so the official app can no longer be installed. Note this is not a signature conflict (INSTALL_FAILED_UPDATE_INCOMPATIBLE is a different error) - do not chase it by clearing app data.

Diagnostic commands:

adb install -r mod.apk
adb shell pm list providers | grep -i "fileprovider"
adb shell dumpsys package com.example.app | grep -iE -A6 "Provider|authority|ContentProvider"
adb shell cmd package dump com.example.app | grep -i "authority"

pm list providers lists every registered provider and its owning package, so you can see who squats on the authority at a glance. The Provider{...} block in dumpsys package shows a single app's authority and grantUriPermissions flag. If there is a real collision, uninstall the squatter or use a build with a correct ${applicationId} placeholder.

One boundary worth drawing: if "Share" actually sends a download link rather than a local file, content:// is not involved at all and the failure belongs on the server side. Rule that out with curl before blaming the URI layer:

curl -sIL -o /dev/null -w "code=%{http_code} type=%{content_type} size=%{size_download}\n" \
  "https://example.com/files/manual.pdf"

A 403 / 404 or text/html means an expired link, missing auth or a CDN misconfiguration - nothing to do with FileProvider.

6. Layer Five: Scoped Storage and Package Visibility Pile On

Android 10 (API 29) introduced scoped storage, so apps can no longer freely read shared directories by absolute path. Android 11 (API 30) tightened package visibility, so queryIntentActivities() / resolveActivity() no longer see undeclared apps by default. Each produces its own "share failed" symptom:

  • Scoped storage: an app still building paths from Environment.getExternalStorageDirectory() and then mapping them through FileProvider will fail to read the source file and throw FileNotFoundException. The correct routes are content://media/... URIs via MediaStore, or ACTION_OPEN_DOCUMENT with a persistable grant. Builds with targetSdkVersion ≤ 28 could temporarily use requestLegacyExternalStorage="true", but that stopped being reliable on Android 11+.
  • Package visibility: an empty share sheet or a chooser with one entry usually means the Manifest has no <queries> block. Apps targeting SDK 30+ must declare which Intent types they want resolved, or the system returns an empty list. This does not affect an explicit grantUriPermission to a named package - only which candidates appear.
aapt dump xmltree app.apk AndroidManifest.xml | grep -iE -A4 "queries|intent>|package=|requestLegacyExternalStorage"
adb shell dumpsys package com.example.app | grep -iE "targetSdk|requestLegacyExternalStorage"

For the full mechanism and <queries> syntax, see the dedicated guide on sideloaded apps not detecting or launching other apps.

7. Nine-Step Diagnostic Path

Follow this order and almost every "share / open attachment" failure lands on a specific layer:

  1. Capture the crash log. Run adb logcat -c && adb logcat -v time | grep -iE "FileUriExposed|FileProvider|Permission Denial|SecurityException|FileNotFound|Failed to find configured root", then reproduce on the phone. FileUriExposedException → layer one; Permission Denial → layer three.
  2. Confirm the URI scheme. Is the logged URI file:// or content://? The former on API 24+ means the app uses an obsolete pattern.
  3. Check OS version and targetSdk. adb shell getprop ro.build.version.release and aapt dump badging app.apk | grep targetSdkVersion. Old targetSdk on a new OS is the most common combination.
  4. Decompile the FileProvider declaration. aapt dump xmltree app.apk AndroidManifest.xml | grep -iE "provider|authorities|grantUriPermissions|FILE_PROVIDER_PATHS". No provider node → the build was stripped or never supported sharing.
  5. Check file_paths roots. unzip -p app.apk res/xml/file_paths.xml (use apktool if the XML is binary-compiled) and confirm the file's real path falls under a declared tag.
  6. Enumerate device providers. adb shell pm list providers | grep -i fileprovider - look for a duplicate or squatted authority.
  7. Verify grant delivery. Use the am start -f 0x00000001 simulation from layer three to separate "no grant issued" from "receiver reads it wrong".
  8. Check scoped storage and package visibility. Inspect requestLegacyExternalStorage and <queries>, and decide whether an empty share sheet is a targetSdk ≥ 30 resolution issue.
  9. Only now blame the build. If all of the above checks out, diff lib/, res/xml/ and AndroidManifest.xml against the official full build to confirm a stripped/clone package. That case has one fix: get the official build.

8. Error and State Lookup Table

Log / errorMeaningLayerNext step
FileUriExposedExceptionA file:// URI crossed an app boundaryURI schemeUse FileProvider or a newer official build
Failed to find configured root that contains ...Path outside declared file_paths.xml rootsConfigAdd the matching <*-path> tag
Permission Denial: opening provider ...Receiver has no read grantTemporary grantAdd flag / ClipData / explicit grant
SecurityException: UID xxx does not have permissionGrant targeted the wrong URI or already expiredTemporary grantCheck grant target and lifetime
FileNotFoundException on content://Source missing, or receiver treated URI as a pathStorage / read pathUse ContentResolver.openInputStream
INSTALL_FAILED_CONFLICTING_PROVIDERAuthority already takenUniquenesspm list providers to find the squatter
IllegalArgumentException: Missing FILE_PROVIDER_PATHSMissing meta-dataConfigStripped build - replace the package
Share sheet empty, no candidates<queries> missingPackage visibilityDeclare queries, or use a compatible build
Blank thumbnail, only first of several files arrivesNo ClipDataTemporary grantAdd setClipData
curl returns 403 / 404The shared item is a dead linkNot a local fileInvestigate server/CDN, not the URI

9. Version Differences at a Glance

Android versionKey changeEffect on sharing
Android 6.0 (API 23) and earlierRuntime permissions introduced; file:// still legalLegacy pattern works
Android 7.0 (API 24)Cross-app file:// banned; StrictMode throwsUnadapted apps crash on Share
Android 8.0 (API 26)Background limits, notification channelsAffects "download in background then share" chains
Android 10 (API 29)Scoped storageAbsolute paths fail; media goes through MediaStore
Android 11 (API 30)Package visibility, scoped storage enforcedShare sheet can be empty
Android 12 (API 31)android:exported must be explicitMissing declaration fails Manifest parsing
Android 13 (API 33)Granular media permissions, notification permissionShared images use READ_MEDIA_IMAGES
Android 14 (API 34)Tighter background / foreground-service rulesAttachment generation needs FGS types

10. Frequently Asked Questions

Q1: Will clearing data or reinstalling fix it?

Almost never for URI-grant problems. Grants are issued per Intent; reinstalling does not change a banned file:// scheme, an authority collision, or missing config. It only helps in the rare case of a stale provider registration.

Q2: Why does sharing to app A work but app B fail?

Two different things: B may call uri.getPath() and treat it as a file path (it should use ContentResolver), or you only ever issued an explicit grant to A. Verify both with am start -f 0x00000001 and compare.

Q3: After installing a "clone / dual" build, the official app will not install. Is this a signature problem?

No. Check whether the error is INSTALL_FAILED_CONFLICTING_PROVIDER - two apps declaring the same hardcoded authority, which is layer four. Signature conflicts report INSTALL_FAILED_UPDATE_INCOMPATIBLE and need a completely different response.

Q4: Can I save a `content://` URI and open it later?

A grant attached to a normal Intent cannot be persisted; it disappears when the task is destroyed or the device reboots. For long-term access use ACTION_OPEN_DOCUMENT plus takePersistableUriPermission(), and note that only DocumentsProviders (the system file picker) support persistable grants - FileProvider does not.

Q5: The share sheet is completely empty. Does that mean I have no apps that can receive the file?

Do not assume so. On targetSdk ≥ 30 with no <queries> block, the system returns an empty list from queryIntentActivities(), so the sheet is empty by construction. Confirm the receiver is installed with adb shell pm list packages, then inspect the Manifest's queries declarations.

Q6: Isn't `root-path` the simplest configuration?

Avoid it. <root-path> maps the entire device / into the shareable range; combined with a sloppy grant it exposes your app's private directories too. Pick the narrowest tag that fits - <cache-path> or <external-files-path>.

Q7: Is disabling StrictMode detection a legitimate fix?

No. disableDeathOnFileUriExposure() only stops the crash. The receiver still has no valid grant, and under scoped storage it will fail to read the file regardless. It hides a symptom.

Q8: The document arrives but the thumbnail is blank. Why?

The thumbnail is a second URI, usually in ClipData or EXTRA_STREAM. The sender granted FLAG_GRANT_READ_URI_PERMISSION on the main URI only. On Android 5.0+ you must also put the URI in setClipData and grant read on it.

Q9: How do I tell an app bug from a damaged sideloaded build?

If all nine steps pass and it still fails, compare package contents: unzip -l for res/xml/ and lib/, aapt dump xmltree for provider and <queries>. If the official build has the config and yours does not, it is a stripped/clone package - replace it.

Q10: Is this the same as "downloaded file not found"?

Different layer. "File not found" means the file landed in an app-private directory under scoped storage and the file manager cannot see it. "Share failed" means the file exists but the URI grant chain across apps is broken. Start the first with download directories and MediaStore, the second with the URI and exception in logcat.

11. Further Reading

Summary

"Sideloaded app cannot share a file" is not one bug. It is a break in one of five layers: URI scheme, FileProvider configuration, temporary grants, authority uniqueness, and scoped storage / package visibility. Keep the order fixed: first prove with adb logcat whether file:// triggered FileUriExposedException, then verify provider and file_paths.xml with aapt dump xmltree, then test grant delivery with am start -f 0x00000001, then rule out authority collisions with pm list providers, and only then check scoped storage, <queries>, and whether the build was stripped. Five steps will locate the cause of nearly every "share failed / cannot open attachment" case - without looping on "reinstall it one more time".