MuntashirAkon/AppManager · error · BackupException

Couldn't get misc.am.tsv for generating checksum

Error message

Couldn't get misc.am.tsv for generating checksum

What it means

At the end of backupExtras(), the misc.am.tsv file is encrypted and its checksum recorded. Failures (IOException or IndexOutOfBoundsException) in encrypt or checksum steps are wrapped in this BackupException even though the file itself was produced.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupOp.java:574

            } catch (IOException e) {
                // Ignore exception
                Log.e(TAG, e);
            }
        }
        // Backup freezeType
        Integer freezeType = FreezeUtils.loadFreezeMethod(mPackageName);
        if (freezeType != null) {
            rules.setFreezeType(freezeType);
        }
        // Commit
        rules.commitExternal(miscFile);
        if (!miscFile.exists()) return;
        try {
            miscFile = mBackupItem.encrypt(new Path[]{miscFile})[0];
            // Store checksum
            mChecksum.add(miscFile.getName(), DigestUtils.getHexDigest(mMetadata.info.checksumAlgo, miscFile));
        } catch (IOException | IndexOutOfBoundsException e) {
            throw new BackupException("Couldn't get misc.am.tsv for generating checksum", e);
        }
    }

    private void backupRules() throws BackupException {
        try {
            Path rulesFile = mBackupItem.getRulesFile();
            try (OutputStream outputStream = rulesFile.openOutputStream();
                 ComponentsBlocker cb = ComponentsBlocker.getInstance(mPackageName, mUserId)) {
                ComponentUtils.storeRules(outputStream, cb.getAll(), true);
            }
            if (!rulesFile.exists()) return;
            rulesFile = mBackupItem.encrypt(new Path[]{rulesFile})[0];
            // Store checksum
            mChecksum.add(rulesFile.getName(), DigestUtils.getHexDigest(mMetadata.info.checksumAlgo, rulesFile));
        } catch (IOException | IndexOutOfBoundsException e) {
            throw new BackupException("Rules backup is requested but encountered an error during fetching rules.", e);
        }
    }

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Check the cause: IndexOutOfBoundsException means encrypt returned an empty array — inspect its filter logic
  2. Verify crypto metadata is present when encryption is requested
  3. Confirm miscFile exists before encrypting (the code checks exists() earlier; re-check if running async)
  4. Regenerate the misc file by rerunning backupExtras if it was removed mid-flow

Example fix

// before
miscFile = mBackupItem.encrypt(new Path[]{miscFile})[0];
// after
Path[] enc = mBackupItem.encrypt(new Path[]{miscFile});
if (enc.length == 0) { Log.w(TAG, "Encryption produced no output for misc.am.tsv"); return; }
miscFile = enc[0];
Defensive patterns

Strategy: try-catch

Validate before calling

if (!miscFile.exists()) return;
Path[] enc = mBackupItem.encrypt(new Path[]{miscFile});
if (enc == null || enc.length == 0) { Log.w(TAG, "encrypt produced nothing"); return; }

Type guard

static Path firstOrNull(Path[] arr) {
    return (arr == null || arr.length == 0) ? null : arr[0];
}

Try / catch

try {
    miscFile = mBackupItem.encrypt(new Path[]{miscFile})[0];
    mChecksum.add(miscFile.getName(), DigestUtils.getHexDigest(...));
} catch (IOException | IndexOutOfBoundsException e) {
    Log.e(TAG, "checksum stage failed for misc.am.tsv", e);
}

Prevention

When it happens

Trigger: mBackupItem.encrypt(new Path[]{miscFile}) throws IOException (crypto config/stream error) or returns an empty array causing [0] to throw IndexOutOfBoundsException; DigestUtils checksum read can also throw IOException.

Common situations: Encrypted backup requested without valid crypto metadata; encrypt() returned no files (filter mismatch on the misc file); file deleted between creation and encryption.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


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