MuntashirAkon/AppManager · error · IOException

Content provider has crashed.

Error message

Content provider has crashed.

What it means

RulesImporter.addRulesFromUri opens an InputStream via ContentResolver.openInputStream(); per the ContentResolver contract this can return null when the provider behind the Uri fails. The importer throws IOException('Content provider has crashed.') in that case because there is no stream to parse TSV rules from.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/rules/RulesImporter.java:61

    private final int[] mUserIds;

    public RulesImporter(@NonNull List<RuleType> typesToImport, @NonNull int[] userIds) {
        if (userIds.length == 0) {
            throw new IllegalArgumentException("Input must contain one or more user handles");
        }
        // Init CBs
        //noinspection unchecked
        mComponentsBlockers = new HashMap[userIds.length];
        for (int i = 0; i < userIds.length; ++i) {
            mComponentsBlockers[i] = new HashMap<>();
        }
        mTypesToImport = typesToImport;
        mUserIds = userIds;
    }

    public void addRulesFromUri(Uri uri) throws IOException {
        try (InputStream inputStream = ContextUtils.getContext().getContentResolver().openInputStream(uri)) {
            if (inputStream == null) throw new IOException("Content provider has crashed.");
            try (BufferedReader TSVFile = new BufferedReader(new InputStreamReader(inputStream))) {
                String dataRow;
                while ((dataRow = TSVFile.readLine()) != null) {
                    RuleEntry entry = RuleEntry.unflattenFromString(null, dataRow, true);
                    // Parse complete, now add the row to CB
                    for (int i = 0; i < mUserIds.length; ++i) {
                        if (mComponentsBlockers[i].get(entry.packageName) == null) {
                            // Get a read-only instance, commit will be called manually
                            mComponentsBlockers[i].put(entry.packageName, ComponentsBlocker.getInstance(entry.packageName, mUserIds[i]));
                        }
                        if (mTypesToImport.contains(entry.type)) {
                            //noinspection ConstantConditions Returned ComponentsBlocker will never be null here
                            mComponentsBlockers[i].get(entry.packageName).addEntry(entry);
                        }
                    }
                }
            }
        }

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Verify the source file still exists and takePersistableUriPermission after SAF picking
  2. Re-select the backup file via ACTION_OPEN_DOCUMENT to get a fresh readable Uri
  3. Catch the IOException and prompt the user to re-pick the import source
  4. Check persisted URI permissions with contentResolver.getPersistedUriPermissions()

Example fix

// before
importer.addRulesFromUri(savedUri);
// after
try {
    importer.addRulesFromUri(savedUri);
} catch (IOException e) {
    launcher.openDocument(); // re-pick the backup file
}
Defensive patterns

Strategy: try-catch

Validate before calling

List<UriPermission> perms = context.getContentResolver().getPersistedUriPermissions();
boolean readable = perms.stream().anyMatch(p -> p.isReadPermission() && p.getUri().equals(uri));
if (!readable) throw new IOException("No read access to import source: " + uri);

Try / catch

try {
    importer.addRulesFromUri(uri);
} catch (IOException e) {
    if (e.getMessage().contains("Content provider has crashed")) {
        promptRepickSource();
    } else throw e;
}

Prevention

When it happens

Trigger: Calling addRulesFromUri(uri) where openInputStream returns null: the source document was deleted after picking, the provider process crashed, or the Uri lacks read grants.

Common situations: Re-importing from a backup Uri whose file was moved/deleted; reading from a documents provider that unmounted (SD card removed); persisted URI permissions revoked.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/2a222fd43a415ff2. Report an issue: GitHub.