MuntashirAkon/AppManager · error · BackupException
Failed to decrypt
Error message
Failed to decrypt
What it means
After locating the APK, backupApkFile() calls ConvertUtils.decryptSourceFiles() to decrypt the source APK if the source backup was encrypted. If decryption throws IOException (I/O failure, corrupt archive, wrong crypto setup), it is wrapped into this BackupException. The message is prefixed with "Failed to decrypt " plus the file list, indicating the APK could not be turned into a readable plaintext file for further processing.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/OABConverter.java:261
return metadataV2;
} catch (JSONException | IOException | CryptoException e) {
return ExUtils.rethrowAsBackupException("Could not parse JSON file.", e);
}
}
private void backupApkFile() throws BackupException {
Path[] baseApkFiles;
try {
baseApkFiles = new Path[]{mBackupLocation.findFile(CryptoUtils.getAppropriateFilename(
mSourceMetadata.apkName, mSourceCryptoMode))};
} catch (FileNotFoundException e) {
throw new BackupException("Could not get base.apk file.", e);
}
// Decrypt APK file if needed
try {
baseApkFiles = ConvertUtils.decryptSourceFiles(baseApkFiles, mSourceCrypto, mSourceCryptoMode, mBackupItem);
} catch (IOException e) {
throw new BackupException("Failed to decrypt " + Arrays.toString(baseApkFiles), e);
}
// baseApkFiles should be a singleton array
if (baseApkFiles.length != 1) {
throw new BackupException("Incorrect number of APK files: " + baseApkFiles.length);
}
Path baseApkFile = baseApkFiles[0];
// Get certificate checksums
try {
String[] checksums = ConvertUtils.getChecksumsFromApk(baseApkFile, mDestMetadata.info.checksumAlgo);
for (int i = 0; i < checksums.length; ++i) {
mChecksum.add(CERT_PREFIX + i, checksums[i]);
}
} catch (Exception ignore) {
}
// Backup APK file
String sourceBackupFilePrefix = BackupUtils.getSourceFilePrefix(getExt(mDestMetadata.info.tarType));
Path[] sourceFiles;
try {View on GitHub (pinned to 0152f468fc)
Solutions
- Verify the source backup's crypto mode and credentials match how the backup was actually encrypted; supply the correct CryptoUtils setup.
- Check the encrypted APK file for corruption (size, readability) and re-copy it from a healthy backup.
- If the source is not encrypted, ensure mSourceCryptoMode reflects that so decryption is skipped rather than attempted.
- Free up storage/verify write permissions for the backup item's working directories — I/O errors during decryption are often disk-related.
Example fix
// before: converting with default (no) crypto while source is encrypted // OABConverter converter = new OABConverter(...); // mSourceCryptoMode unset // after: supply the correct source crypto mode so decryption succeeds // converter.setSourceCryptoMode(CryptoUtils.MODE_GCM); // matches the backup
Defensive patterns
Strategy: try-catch
Validate before calling
Path encryptedApk = backupLocation.findFile(expectedName);
if (sourceCrypto != null) {
if (!encryptedApk.isReadable() || encryptedApk.size() == 0) {
throw new IOException("Encrypted APK unreadable or empty: " + encryptedApk);
}
} Try / catch
try {
converter.convert(...);
} catch (BackupException e) {
if (e.getMessage().startsWith("Failed to decrypt")) {
Log.e(TAG, "Decryption failed; check source crypto params and file integrity", e.getCause());
}
} Prevention
- Supply the exact crypto parameters used when the source backup was encrypted.
- Check free disk space before decryption — output is written to a working dir.
- Validate encrypted files are complete (not truncated by interrupted transfers).
When it happens
Trigger: backupApkFile() calls ConvertUtils.decryptSourceFiles(baseApkFiles, mSourceCrypto, mSourceCryptoMode, mBackupItem) and it throws IOException at OABConverter.java:261 — e.g. unreadable/corrupt encrypted file or a failing crypto stream.
Common situations: Converting an encrypted OAndBackup backup with wrong or missing crypto parameters; truncated/corrupted encrypted APK due to interrupted backup or bad storage; crypto implementation/key mismatch between the app that encrypted and the converter.
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
- Failed to write checksums.txt
- Failed to decrypt ${Arrays.toString(dataFiles)}
- Failed to decrypt ${miscFile.getName()}
- Failed to encrypt
- Failed to encrypt
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/65dab027456db024.
Report an issue: GitHub.