MuntashirAkon/AppManager · error · BackupException
Failed to decrypt ${Arrays.toString(backupSourceFiles)}
Error message
Failed to decrypt ${Arrays.toString(backupSourceFiles)} What it means
After staging the APK file placeholders, restoreApkFiles decrypts the backup's APK source files via mBackupItem.decrypt(). This error means decryption of one or more of those encrypted files threw an IOException — the encrypted data could not be read or transformed back to plaintext. It aborts the APK restoration phase.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java:355
final int splitCount = mBackupMetadata.splitConfigs.length;
String[] allApkNames = new String[splitCount + 1];
Path[] allApks = new Path[splitCount + 1];
try {
Path baseApk = packageStagingDirectory.createNewFile(mBackupMetadata.apkName, null);
allApks[0] = baseApk;
allApkNames[0] = mBackupMetadata.apkName;
for (int i = 1; i < allApkNames.length; ++i) {
allApkNames[i] = mBackupMetadata.splitConfigs[i - 1];
allApks[i] = packageStagingDirectory.createNewFile(allApkNames[i], null);
}
} catch (IOException e) {
throw new BackupException("Could not create staging files", e);
}
// Decrypt sources
try {
backupSourceFiles = mBackupItem.decrypt(backupSourceFiles);
} catch (IOException e) {
throw new BackupException("Failed to decrypt " + Arrays.toString(backupSourceFiles), e);
}
// Extract apk files to the package staging directory
try {
TarUtils.extract(mBackupInfo.tarType, backupSourceFiles, packageStagingDirectory, allApkNames, null, null);
} catch (Throwable th) {
throw new BackupException("Failed to extract the apk file(s).", th);
}
// A normal update will do it now
InstallerOptions options = InstallerOptions.getDefault();
options.setInstallerName(mBackupMetadata.installer);
options.setUserId(mUserId);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
options.setInstallScenario(PackageManager.INSTALL_SCENARIO_BULK);
}
AtomicReference<String> status = new AtomicReference<>();
PackageInstallerCompat packageInstaller = PackageInstallerCompat.getNewInstance();
packageInstaller.setOnInstallListener(new PackageInstallerCompat.OnInstallListener() {
@OverrideView on GitHub (pinned to 0152f468fc)
Solutions
- Re-download or re-copy the backup; the encrypted APK archive is likely truncated or corrupted.
- Verify the backup was taken with a compatible AppManager version and encryption settings.
- Check that all files in the backup item exist and are readable before decrypting.
- Retry the restore; transient I/O errors (e.g. on external storage) can cause spurious failures.
Example fix
// before
backupSourceFiles = mBackupItem.decrypt(backupSourceFiles);
// after
for (Path f : backupSourceFiles) {
if (f.getLength() <= 0) throw new BackupException("Encrypted file empty/corrupt: " + f);
}
backupSourceFiles = mBackupItem.decrypt(backupSourceFiles); Defensive patterns
Strategy: try-catch
Validate before calling
for (Path f : encryptedFiles) { if (!f.exists() || f.length() == 0) throw new IOException("Missing/empty encrypted file: " + f); } Try / catch
try { files = backupItem.decrypt(files); } catch (IOException e) { throw new BackupException("Failed to decrypt " + Arrays.toString(files) + " — verify backup integrity and encryption settings", e); } Prevention
- Verify backup integrity (checksums) before starting restore
- Keep encryption credentials/keys consistent between backup and restore
- Transfer backups with integrity-checked methods (checksum after copy)
- Test decrypt on a small file before the full restore
When it happens
Trigger: mBackupItem.decrypt(backupSourceFiles) throws IOException: encrypted APK files missing/corrupt, wrong cipher/key, truncated tar members, or I/O failure reading the encrypted files.
Common situations: Partial backup copies; encryption scheme changes between AppManager versions; key/password mismatch.
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
- Couldn't delete old file <inputFile>
- Failed to write checksums.txt
- Failed to encrypt
- Master key existed when the checksum was made but now it doe
- Master key exists but it didn't exist when the backup was ma
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/810b5630dfe0b17b.
Report an issue: GitHub.