MuntashirAkon/AppManager · error · BackupException
Could not read backup metadata. Possibly due to a malformed
Error message
Could not read backup metadata. Possibly due to a malformed json file.
What it means
RestoreOp reads metadata.json via mBackupItem.getMetadata(mBackupInfo); an IOException is wrapped as BackupException saying the backup metadata JSON is likely malformed. This occurs after crypto setup succeeds, so the metadata file exists but cannot be parsed/decrypted readably.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java:134
mBackupItem.cleanup();
throw new BackupException("Could not read backup info. Possibly due to a malformed json file.", e);
}
// Setup crypto
if (!CryptoUtils.isAvailable(mBackupInfo.crypto)) {
mBackupItem.cleanup();
throw new BackupException("Mode " + mBackupInfo.crypto + " is currently unavailable.");
}
try {
mBackupItem.setCrypto(mBackupInfo.getCrypto());
} catch (CryptoException e) {
mBackupItem.cleanup();
throw new BackupException("Could not get crypto " + mBackupInfo.crypto, e);
}
try {
mBackupMetadata = mBackupItem.getMetadata(mBackupInfo).metadata;
} catch (IOException e) {
mBackupItem.cleanup();
throw new BackupException("Could not read backup metadata. Possibly due to a malformed json file.", e);
}
// Get checksums
try {
mChecksum = mBackupItem.getChecksum();
} catch (Throwable e) {
mBackupItem.cleanup();
throw new BackupException("Failed to get checksums.", e);
}
// Verify metadata
if (!requestedFlags.skipSignatureCheck()) {
try {
verifyMetadata();
} catch (BackupException e) {
mBackupItem.cleanup();
throw e;
}
}
// Check user handleView on GitHub (pinned to 0152f468fc)
Solutions
- Verify metadata.json inside the (decrypted) backup is valid JSON and non-empty
- Re-copy the backup directory completely; do not edit metadata.json manually
- Confirm the app version supports the metadata format of the backup (v2/v5 schema differences)
- Re-create the backup if the metadata file is unrecoverable
Example fix
// before
mBackupMetadata = mBackupItem.getMetadata(mBackupInfo).metadata;
// after
File metaFile = new File(backupDir, "metadata.json");
if (!metaFile.exists() || metaFile.length() == 0) {
throw new BackupException("metadata.json is missing or empty; backup copy is incomplete.");
}
mBackupMetadata = mBackupItem.getMetadata(mBackupInfo).metadata; Defensive patterns
Strategy: validation
Validate before calling
File meta = new File(backupDir, "metadata.json");
if (!meta.isFile() || meta.length() == 0) throw new BackupException("metadata.json missing/empty in " + backupDir); Type guard
boolean hasMetadata(Path dir) { return dir.resolve("metadata.json").toFile().isFile(); } Try / catch
try { new RestoreOp(...); } catch (BackupException e) { if (e.getMessage().contains("Could not read backup metadata")) { validateJsonOrRecreateBackup(); } throw e; } Prevention
- Never edit metadata.json manually
- Include metadata.json when migrating backups between devices
- Confirm format-version compatibility (v2 vs v5) before restoring
When it happens
Trigger: getMetadata throws IOException because metadata.json is corrupt, truncated, empty, or was not decrypted properly (wrong crypto producing garbage).
Common situations: metadata.json lost during partial backup copy; file corrupted by editing or transfer; decryption succeeded at file level but content is invalid due to version mismatch between backup and app formats.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Could not read backup info. Possibly due to a malformed json
- Android System (android) cannot be restored.
- Restore is requested without any flags.
- No base backup found.
- Could not get backup files.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/06bcb4bb59d7ef99.
Report an issue: GitHub.