MuntashirAkon/AppManager · error · BackupException

Failed to encrypt checksums.txt

Error message

Failed to encrypt checksums.txt

What it means

SBConverter.convert throws BackupException('Failed to encrypt checksums.txt') when mBackupItem.encrypt on the checksum file throws IOException. The checksums.txt must be encrypted to match the backup's crypto settings before commit; failure aborts conversion. The cause IOException is dropped here as well.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/SBConverter.java:141

            }
            if (mDestMetadata.info.flags.backupData()) {
                backupData();
            }
            // Write modified metadata
            try {
                Map<String, String> filenameChecksumMap = MetadataManager.writeMetadata(mDestMetadata, mBackupItem);
                for (Map.Entry<String, String> filenameChecksumPair : filenameChecksumMap.entrySet()) {
                    mChecksum.add(filenameChecksumPair.getKey(), filenameChecksumPair.getValue());
                }
            } catch (IOException e) {
                throw new BackupException("Failed to write metadata.");
            }
            mChecksum.close();
            // Encrypt checksum
            try {
                mBackupItem.encrypt(new Path[]{mChecksum.getFile()});
            } catch (IOException e) {
                throw new BackupException("Failed to encrypt checksums.txt");
            }
            // Replace current backup
            try {
                mBackupItem.commit();
            } catch (IOException e) {
                throw new BackupException("Could not finalise backup.", e);
            }
            backupSuccess = true;
        } catch (BackupException e) {
            throw e;
        } catch (Throwable th) {
            throw new BackupException("Unknown error occurred.", th);
        } finally {
            mBackupItem.cleanup();
            mCachedApk.requireParent().delete();
            if (backupSuccess) {
                BackupUtils.putBackupToDbAndBroadcast(ContextUtils.getContext(), mDestMetadata);
            }

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Verify the destination crypto key/password is correct
  2. Ensure mChecksum was closed successfully and its file still exists before encrypt
  3. Check free space in the backup directory
  4. Check logcat for the original IOException since the BackupException omits the cause

Example fix

// before
throw new BackupException("Failed to encrypt checksums.txt");
// after
throw new BackupException("Failed to encrypt checksums.txt", e);
Defensive patterns

Strategy: try-catch

Validate before calling

File checksumFile = new File(mChecksum.getFile().getUri().getPath());
if (!checksumFile.exists() || checksumFile.length() == 0) {
    throw new IOException("checksums.txt missing or empty before encryption");
}

Try / catch

try {
    converter.convert(...);
} catch (BackupException e) {
    if ("Failed to encrypt checksums.txt".equals(e.getMessage())) {
        // verify crypto key and destination storage, then retry
    }
}

Prevention

When it happens

Trigger: Encrypting the checksum file fails: crypto provider/key error surfaced as IOException, missing source checksum file, or destination I/O failure during encryption write.

Common situations: Destination crypto key/password mismatch; storage full while writing encrypted output; checksum file deleted or closed incorrectly before encryption.

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


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