MuntashirAkon/AppManager · error
Content provider has crashed.
Error message
Content provider has crashed.
What it means
RulesExporter.saveRules opens an OutputStream on the destination Uri via ContentResolver.openOutputStream(). The contract allows openOutputStream to return null; when it does, the exporter throws IOException('Content provider has crashed.') because the content provider backing the Uri failed to supply a writable stream.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/rules/RulesExporter.java:45
@Nullable
private List<String> mPackagesToExport;
@NonNull
private final List<RuleType> mTypesToExport;
@NonNull
private final int[] mUserIds;
public RulesExporter(@NonNull List<RuleType> typesToExport, @Nullable List<String> packagesToExport,
@NonNull int[] userIds) {
mContext = ContextUtils.getContext();
mPackagesToExport = packagesToExport;
mTypesToExport = typesToExport;
mUserIds = userIds;
}
public void saveRules(Uri uri) throws IOException {
if (mPackagesToExport == null) mPackagesToExport = ComponentUtils.getAllPackagesWithRules(mContext);
try (OutputStream outputStream = mContext.getContentResolver().openOutputStream(uri)) {
if (outputStream == null) throw new IOException("Content provider has crashed.");
for (String packageName: mPackagesToExport) {
for (int userHandle : mUserIds) {
// Get a read-only instance
try (ComponentsBlocker cb = ComponentsBlocker.getInstance(packageName, userHandle)) {
ComponentUtils.storeRules(outputStream, cb.getAll(mTypesToExport), true);
}
}
}
}
}
}
View on GitHub (pinned to 0152f468fc)
Solutions
- Re-pick the export destination via SAF (ACTION_CREATE_DOCUMENT) to get a fresh writable Uri
- Verify the Uri is writable (check provider grants, use FLAG_GRANT_WRITE_URI_PERMISSION)
- Catch the IOException and surface a retry to the user instead of failing silently
- Retry the export after confirming the storage provider is available
Example fix
// before
exporter.saveRules(destinationUri);
// after
try {
exporter.saveRules(destinationUri);
} catch (IOException e) {
Toast.show("Export failed: destination provider unavailable, pick a new location");
} Defensive patterns
Strategy: try-catch
Validate before calling
try (OutputStream os = context.getContentResolver().openOutputStream(uri)) {
if (os == null) throw new IOException("Destination provider unavailable");
} // verify writability before starting the real export Try / catch
try {
exporter.saveRules(uri);
} catch (IOException e) {
if (e.getMessage().contains("Content provider has crashed")) {
promptRepickDestination();
} else throw e;
} Prevention
- Use SAF document Uris with write grants, not raw file:// paths
- Take persistable permissions when the user picks a destination
- Check available storage and provider availability before exporting
When it happens
Trigger: Calling saveRules(uri) with a Uri whose provider returns null from openOutputStream: unwritable SAF target, provider crashed or was killed, or a Uri from a provider lacking write permission.
Common situations: Exporting rules to a cloud-storage or documents-provider location that disconnects mid-session; targeting a file:// Uri without proper grants; provider process death under memory pressure.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Content provider has crashed.
- Invalid export type: {exportType}
- Could not get backup files.
- Could not retrieve metadata from backup.
- Failed to create checksum file.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/343872b39b48376b.
Report an issue: GitHub.