MuntashirAkon/AppManager · error · BackupException
Android System (android) cannot be restored.
Error message
Android System (android) cannot be restored.
What it means
BackupManager.restore() unconditionally rejects restore operations for the package name 'android' (the Android system package). Restoring a backup over the live system package is considered unsafe/unsupported, so the method throws BackupException immediately before doing any work. This is a deliberate guard, not a failure state.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupManager.java:97
}
if (progressHandler != null) {
int max = calculateMaxProgress(options.flags);
progressHandler.setProgressTextInterface(ProgressHandler.PROGRESS_PERCENT);
progressHandler.postUpdate(max, 0f);
}
try (BackupOp backupOp = new BackupOp(options.packageName, options.flags, backupItem, options.userId)) {
backupOp.runBackup(progressHandler);
BackupUtils.putBackupToDbAndBroadcast(ContextUtils.getContext(), backupOp.getMetadata());
}
}
/**
* Restore a single backup for a given package belonging to the given package
*/
public void restore(@NonNull RestoreOpOptions options, @Nullable ProgressHandler progressHandler)
throws BackupException {
if (options.packageName.equals("android")) {
throw new BackupException("Android System (android) cannot be restored.");
}
if (options.flags.isEmpty()) {
throw new BackupException("Restore is requested without any flags.");
}
BackupItems.BackupItem backupItem;
try {
if (options.relativeDir != null) {
backupItem = BackupItems.findBackupItem(options.relativeDir);
} else {
// Use base backup
Backup baseBackup = BackupUtils.retrieveBaseBackupFromDb(options.userId, options.packageName);
if (baseBackup != null) {
backupItem = baseBackup.getItem();
} else {
throw new BackupException("No base backup found.");
}
}
} catch (IOException e) {View on GitHub (pinned to 0152f468fc)
Solutions
- Exclude the 'android' package from the set of packages passed to restore()/restoreBackups().
- If a batch op, filter the package list before building RestoreOpOptions and skip/log 'android' entries.
- If you truly need system-partition data, restore it via a root-based tool (e.g. TWRP/custom recovery), not AppManager's restore path.
- Catch BackupException per-package in batch loops so one bad entry doesn't abort the whole run.
Example fix
// before
manager.restore(new RestoreOpOptions("android", userId, flags), progress);
// after
if (!"android".equals(options.packageName)) {
manager.restore(options, progress);
} Defensive patterns
Strategy: validation
Validate before calling
if ("android".equals(options.packageName)) {
throw new IllegalArgumentException("Refusing to restore system package 'android'");
}
manager.restore(options, progress); Type guard
boolean isRestorable(String pkg) { return pkg != null && !pkg.equals("android"); } Try / catch
try {
manager.restore(options, progress);
} catch (BackupException e) {
if (e.getMessage().contains("cannot be restored")) { /* skip system pkg */ }
} Prevention
- Filter 'android' out of package lists before batch restore
- Validate packageName before constructing RestoreOpOptions
When it happens
Trigger: Calling restore() (directly or via restoreBackups or any of the testRestoreV4* helpers) with RestoreOpOptions whose packageName equals "android".
Common situations: Batch-restore jobs iterating over every backed-up package, where the 'android' system backup captured during a custom backup is included in the list; scripting restores without filtering out the system package.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Restore is requested without any flags.
- Android System (android) cannot be backed up.
- Backup 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/c5470a83c20c7cb4.
Report an issue: GitHub.