MuntashirAkon/AppManager · error · BackupException
Failed to write metadata.
Error message
Failed to write metadata.
What it means
SBConverter.convert throws BackupException('Failed to write metadata.') when MetadataManager.writeMetadata throws IOException while serializing destination metadata files into the backup. Note this rethrow drops the cause (no 'e' argument), hiding the root IOException.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/SBConverter.java:134
} catch (IOException e) {
throw new BackupException("Failed to create checksum file.", e);
}
// Backup icon
backupIcon();
if (mDestMetadata.info.flags.backupApkFiles()) {
backupApkFile();
}
if (mDestMetadata.info.flags.backupData()) {
backupData();
}
// Write modified metadata
try {
Map<String, String> filenameChecksumMap = MetadataManager.writeMetadata(mDestMetadata, mBackupItem);
for (Map.Entry<String, String> filenameChecksumPair : filenameChecksumMap.entrySet()) {
mChecksum.add(filenameChecksumPair.getKey(), filenameChecksumPair.getValue());
}
} catch (IOException e) {
throw new BackupException("Failed to write metadata.");
}
mChecksum.close();
// Encrypt checksum
try {
mBackupItem.encrypt(new Path[]{mChecksum.getFile()});
} catch (IOException e) {
throw new BackupException("Failed to encrypt checksums.txt");
}
// Replace current backup
try {
mBackupItem.commit();
} catch (IOException e) {
throw new BackupException("Could not finalise backup.", e);
}
backupSuccess = true;
} catch (BackupException e) {
throw e;
} catch (Throwable th) {View on GitHub (pinned to 0152f468fc)
Solutions
- Check free space and writability of the backup destination
- Inspect the original IOException in logcat since the BackupException omits the cause
- Remove stale backup directories for the same package/name and retry
- Verify storage permissions before conversion
Example fix
// before
} catch (IOException e) {
throw new BackupException("Failed to write metadata.");
}
// after
} catch (IOException e) {
throw new BackupException("Failed to write metadata.", e);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (mDestMetadata == null || mDestMetadata.info == null) {
throw new IllegalStateException("Destination metadata not initialized before write");
} Try / catch
try {
converter.convert(...);
} catch (BackupException e) {
if ("Failed to write metadata.".equals(e.getMessage())) {
// check logcat for the suppressed IOException cause; fix storage and retry
}
} Prevention
- Ensure metadata is fully populated before writing
- Check destination writability/free space
- Initialize mChecksum and backup item before metadata write
When it happens
Trigger: writeMetadata fails writing the metadata JSON files to the backup directory — unwritable directory, full storage, or I/O error during file creation.
Common situations: Destination storage full or read-only; stale backup directories with leftover files; filesystem errors on emulated storage.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Could not retrieve metadata from backup.
- Failed to write metadata.
- Could not get backup files.
- Failed to setup metadata.
- Failed to create checksum file.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/0cb55a232bb27045.
Report an issue: GitHub.