MuntashirAkon/AppManager · error · BackupException
Could not read backup info. Possibly due to a malformed json
Error message
Could not read backup info. Possibly due to a malformed json file.
What it means
RestoreOp's constructor reads backup.json via mBackupItem.getInfo(); an IOException there is rethrown as BackupException stating the backup info JSON is likely malformed. The constructor aborts and cleans up the BackupItem before any restore work starts.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java:117
private int mUid;
@NonNull
private final BackupItems.Checksum mChecksum;
private final int mUserId;
private boolean mIsInstalled;
private boolean mRequiresRestart;
RestoreOp(@NonNull String packageName, @NonNull BackupFlags requestedFlags,
@NonNull BackupItems.BackupItem backupItem, int userId) throws BackupException {
mPackageName = packageName;
mRequestedFlags = requestedFlags;
mBackupItem = backupItem;
mUserId = userId;
try {
mBackupInfo = mBackupItem.getInfo();
mBackupFlags = mBackupInfo.flags;
} catch (IOException e) {
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);
}View on GitHub (pinned to 0152f468fc)
Solutions
- Check that backup.json exists and is valid JSON inside the backup directory (validate with a JSON parser)
- Re-copy the backup folder intact; verify file sizes after transfer
- Restore file read permissions on the backup directory for the app
- If the backup cannot be repaired, re-create the backup from the source device
Example fix
// before
mBackupInfo = mBackupItem.getInfo();
// after
File info = new File(backupDir, "backup.json");
if (!info.exists() || info.length() == 0) {
throw new BackupException("backup.json is missing or empty in " + backupDir);
}
mBackupInfo = mBackupItem.getInfo(); // malformed JSON still surfaces as this error Defensive patterns
Strategy: validation
Validate before calling
File f = new File(backupDir, "backup.json");
if (!f.isFile() || f.length() == 0) throw new BackupException("backup.json missing/empty in " + backupDir);
try (Reader r = new FileReader(f)) { new JsonParser().parse(r); } catch (JsonParseException e) { throw new BackupException("backup.json is not valid JSON", e); } Type guard
boolean hasValidBackupInfo(Path dir) { File f = dir.resolve("backup.json").toFile(); return f.isFile() && f.length() > 0; } Try / catch
try { new RestoreOp(...); } catch (BackupException e) { if (e.getMessage().contains("malformed json")) { reportCorruptBackup(backupDir); } throw e; } Prevention
- Copy backup directories as a whole and verify file counts/sizes afterwards
- Never hand-edit backup.json
- Validate JSON after every backup transfer before deleting the source
When it happens
Trigger: mBackupItem.getInfo() throws IOException because backup.json is missing, unreadable, or fails JSON parsing (corrupt/empty file, wrong charset, truncated transfer).
Common situations: Backups copied off-device incompletely (no backup.json), file corrupted by cloud sync or MTP transfer, user renamed/edited backup.json manually, or permissions prevent reading the backup directory.
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 metadata. Possibly due to a malformed
- 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/ba396438e8f29990.
Report an issue: GitHub.