MuntashirAkon/AppManager · error · BackupException

Rules file is missing.

Error message

Rules file is missing.

What it means

Thrown by restoreRules when reading the backup's rules file via mBackupItem.getRulesFile() throws IOException while the backup metadata claims hasRules == true. In other words, the metadata says rules exist, but the actual rules archive/file cannot be found or read, so the restore cannot proceed silently.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java:762

        }
        try {
            rules.loadExternalEntries(miscFile);
        } catch (Throwable e) {
            throw new BackupException("Failed to load rules from misc.", e);
        }
    }

    private void restoreRules() throws BackupException {
        // Apply rules
        if (!mIsInstalled) {
            throw new BackupException("Rules restore is requested but the app isn't installed.");
        }
        Path rulesFile;
        try {
            rulesFile = mBackupItem.getRulesFile();
        } catch (IOException e) {
            if (mBackupMetadata.hasRules) {
                throw new BackupException("Rules file is missing.", e);
            } else {
                // There are no rules, just skip
                return;
            }
        }
        if (!mRequestedFlags.skipSignatureCheck()) {
            String checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, rulesFile);
            if (!checksum.equals(mChecksum.get(rulesFile.getName()))) {
                throw new BackupException("Couldn't verify permission file." +
                        "\nFile: " + rulesFile +
                        "\nFound: " + checksum +
                        "\nRequired: " + mChecksum.get(rulesFile.getName()));
            }
        }
        // Decrypt rules file
        try {
            rulesFile = mBackupItem.decrypt(new Path[]{rulesFile})[0];
        } catch (IOException | IndexOutOfBoundsException e) {

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Re-copy the complete backup directory including the rules file
  2. If the rules file is intentionally absent, fix/clear hasRules in Metadata.json or use a backup without the rules flag
  3. Skip the rules-restore option and apply rules manually after data restore
  4. Check storage permissions/paths so getRulesFile() can actually read the backup location

Example fix

// before
if (mBackupMetadata.hasRules) {
    throw new BackupException("Rules file is missing.", e);
}
// after
if (mBackupMetadata.hasRules) {
    Log.w(TAG, "Metadata says rules exist but the file is missing; skipping rules restore", e);
    return;
}
Defensive patterns

Strategy: validation

Validate before calling

File rulesFile = new File(backupDir, "rules.json");
if (metadata.hasRules && !rulesFile.exists()) {
    flags.restoreRules = false;
}

Try / catch

try {
    restoreOp.runRestore();
} catch (BackupException e) {
    if ("Rules file is missing.".equals(e.getMessage())) {
        Log.w(TAG, "Rules file missing; continuing without rules", e.getCause());
    } else throw e;
}

Prevention

When it happens

Trigger: getRulesFile() throws IOException (file missing from backup dir, unreadable path) AND mBackupMetadata.hasRules is true — an inconsistency between metadata and actual backup contents.

Common situations: Rules file (rules.json / rules archive) was not copied with the backup; backup partially transferred; metadata edited or stale after files were removed; storage permission issues making the file unreadable.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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