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

VerifyOp reads the (decrypted) metadata file via mBackupItem.getMetadata(mBackupInfo). If parsing the metadata JSON throws IOException, cleanup() runs and this BackupException is thrown — the metadata file is absent, unreadable, or not valid JSON, mirroring error 153 but for the metadata file rather than backup.json.

Solutions

  1. Re-copy the complete backup including the metadata file.
  2. Confirm the crypto credentials are correct so metadata decrypts to valid JSON.
  3. Recreate the backup from the source device if metadata is unrecoverable.
  4. Validate the decrypted metadata with a JSON linter to spot structural corruption.

Example fix

// before: metadata missing from copied backup dir
backup/
  backup.json
// after: full backup directory
backup/
  backup.json
  metadata.json.enc
  ...
Defensive patterns

Strategy: validation

Validate before calling

// Decrypt and JSON-validate metadata before verify
byte[] meta = decrypt(metadataFile); // with correct credentials
new JSONObject(new String(meta)); // throws early if garbage/invalid

Try / catch

try {
    new VerifyOp(backupItem).verify();
} catch (BackupException e) {
    if (e.getMessage().contains("Could not read backup metadata")) {
        // wrong key or missing/truncated metadata file: re-copy backup or fix credentials
    }
}

Prevention

When it happens

Trigger: verify() on a backup where the encrypted metadata cannot be decrypted into valid JSON (wrong key silently producing garbage handled as IO failure), the metadata file is missing from the backup directory, or it was truncated in transfer.

Common situations: Partial backup copies, wrong decryption key yielding an undecryptable blob, backups moved between devices with interrupted file sync, or manually pruned backup directories.

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.

Related errors


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

Appendix: source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/VerifyOp.java:56

            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("Could not get checksums.", e);
        }
        // Verify metadata
        try {
            verifyMetadata();
        } catch (BackupException e) {
            mBackupItem.cleanup();
            throw e;
        }
    }

    @Override

View on GitHub (pinned to 0152f468fc)