MuntashirAkon/AppManager · critical · BackupException

Data file verification failed for index ${i}.\nFile: ${file}

Error message

Data file verification failed for index ${i}.\nFile: ${file}\nFound: ${checksum}\nRequired: ${mChecksum.get(file.getName())}

What it means

Integrity verification in restoreData computes the digest of each data backup file with mBackupInfo.checksumAlgo and compares it to the value recorded in mChecksum. If the computed checksum differs from the expected one, this BackupException is thrown with the file, found and required digests. It guarantees a data backup was modified or corrupted after being created.

Source

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

    private void restoreData() throws BackupException {
        // Data restore is requested: Data restore is only possible if the app is actually
        // installed. So, check if it's installed first.
        if (mPackageInfo == null) {
            throw new BackupException("Data restore is requested but the app isn't installed.");
        }
        if (!mRequestedFlags.skipSignatureCheck()) {
            // Verify integrity of the data backups
            String checksum;
            for (int i = 0; i < mBackupMetadata.dataDirs.length; ++i) {
                Path[] dataFiles = mBackupItem.getDataFiles(i);
                if (dataFiles.length == 0) {
                    throw new BackupException("Data restore is requested but there are no data files for index " + i + ".");
                }
                for (Path file : dataFiles) {
                    checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, file);
                    if (!checksum.equals(mChecksum.get(file.getName()))) {
                        throw new BackupException("Data file verification failed for index " + i + "." +
                                "\nFile: " + file +
                                "\nFound: " + checksum +
                                "\nRequired: " + mChecksum.get(file.getName()));
                    }
                }
            }
        }
        // Force-stop and clear app data
        PackageManagerCompat.clearApplicationUserData(mPackageName, mUserId);
        // Restore backups
        for (int i = 0; i < mBackupMetadata.dataDirs.length; ++i) {
            String backupDataDir = mBackupMetadata.dataDirs[i];
            if (backupDataDir.equals(BackupManager.DATA_BACKUP_SPECIAL_ADB)) {
                // Adb backup restore
                restoreAdb(i);
            } else {
                // Regular directory restore
                restoreDirectory(mBackupMetadata.dataDirs[i], i);

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Re-copy the backup from its original source and retry — the file was likely corrupted in transit.
  2. Re-create the backup from a healthy installation; the data files cannot be trusted.
  3. Verify mBackupInfo.checksumAlgo matches the algorithm used to generate the checksums file.
  4. As a last resort, skip signature check via skipSignatureCheck() flag, accepting the risk of corrupt data.

Example fix

// before: restoring after suspicious transfer
ew RestoreOp(...).runRestore(); // BackupException: verification failed
// after: verify manually first
String found = DigestUtils.getHexDigest("SHA-256", dataFile);
String expected = checksums.get(dataFile.getName());
if (!found.equals(expected)) {
    reCopyBackupFromSource(); // then restore
}
Defensive patterns

Strategy: validation

Validate before calling

String found = DigestUtils.getHexDigest(info.checksumAlgo, dataFile);
if (!found.equals(checksums.get(dataFile.getName())))
    throw new IllegalStateException("Corrupt backup file: " + dataFile);

Type guard

boolean checksumOk(Map<String,String> sums, String algo, Path f) {
    return sums.containsKey(f.getName()) &&
        sums.get(f.getName()).equals(DigestUtils.getHexDigest(algo, f));
}

Try / catch

try { runRestore(); } catch (BackupException e) {
    if (e.getMessage().contains("Data file verification failed")) {
        // message embeds File/Found/Required lines — log and re-fetch backup
        Log.e(TAG, e.getMessage());
        reCopyBackupAndRetry();
    } else throw e;
}

Prevention

When it happens

Trigger: Any data backup file's digest mismatches the checksums file: file edited/truncated in place, corrupted transfer, wrong checksum algorithm applied, or checksums file regenerated while data files changed.

Common situations: Backups synced via cloud/USB with corruption; user renamed/recompressed tar files; restoring a backup that was modified by another tool; checksum algorithm (e.g. MD5 vs SHA-256) mismatch after a version change.

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/53290da039c0905f. Report an issue: GitHub.