{"record":{"id":"c5470a83c20c7cb4","repo":"MuntashirAkon/AppManager","slug":"android-system-android-cannot-be-restored","errorCode":null,"errorMessage":"Android System (android) cannot be restored.","messagePattern":"Android System \\(android\\) cannot be restored\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupManager.java","lineNumber":97,"sourceCode":"        }\n        if (progressHandler != null) {\n            int max = calculateMaxProgress(options.flags);\n            progressHandler.setProgressTextInterface(ProgressHandler.PROGRESS_PERCENT);\n            progressHandler.postUpdate(max, 0f);\n        }\n        try (BackupOp backupOp = new BackupOp(options.packageName, options.flags, backupItem, options.userId)) {\n            backupOp.runBackup(progressHandler);\n            BackupUtils.putBackupToDbAndBroadcast(ContextUtils.getContext(), backupOp.getMetadata());\n        }\n    }\n\n    /**\n     * Restore a single backup for a given package belonging to the given package\n     */\n    public void restore(@NonNull RestoreOpOptions options, @Nullable ProgressHandler progressHandler)\n            throws BackupException {\n        if (options.packageName.equals(\"android\")) {\n            throw new BackupException(\"Android System (android) cannot be restored.\");\n        }\n        if (options.flags.isEmpty()) {\n            throw new BackupException(\"Restore is requested without any flags.\");\n        }\n        BackupItems.BackupItem backupItem;\n        try {\n            if (options.relativeDir != null) {\n                backupItem = BackupItems.findBackupItem(options.relativeDir);\n            } else {\n                // Use base backup\n                Backup baseBackup = BackupUtils.retrieveBaseBackupFromDb(options.userId, options.packageName);\n                if (baseBackup != null) {\n                    backupItem = baseBackup.getItem();\n                } else {\n                    throw new BackupException(\"No base backup found.\");\n                }\n            }\n        } catch (IOException e) {","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupManager.java#L79-L115","documentation":"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.","triggerScenarios":"Calling restore() (directly or via restoreBackups or any of the testRestoreV4* helpers) with RestoreOpOptions whose packageName equals \"android\".","commonSituations":"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.","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."],"exampleFix":"// before\nmanager.restore(new RestoreOpOptions(\"android\", userId, flags), progress);\n// after\nif (!\"android\".equals(options.packageName)) {\n    manager.restore(options, progress);\n}","handlingStrategy":"validation","validationCode":"if (\"android\".equals(options.packageName)) {\n    throw new IllegalArgumentException(\"Refusing to restore system package 'android'\");\n}\nmanager.restore(options, progress);","typeGuard":"boolean isRestorable(String pkg) { return pkg != null && !pkg.equals(\"android\"); }","tryCatchPattern":"try {\n    manager.restore(options, progress);\n} catch (BackupException e) {\n    if (e.getMessage().contains(\"cannot be restored\")) { /* skip system pkg */ }\n}","preventionTips":["Filter 'android' out of package lists before batch restore","Validate packageName before constructing RestoreOpOptions"],"tags":["android","backup","restore","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}