{"record":{"id":"a5bb841c5e7246e0","repo":"MuntashirAkon/AppManager","slug":"the-app-has-keystore-items-and-keystore-backup-isn-t-enabled","errorCode":null,"errorMessage":"The app has keystore items and KeyStore backup isn't enabled.","messagePattern":"The app has keystore items and KeyStore backup isn't enabled\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupOp.java","lineNumber":157,"sourceCode":"            throw new BackupException(\"Failed to create checksum file.\", e);\n        }\n    }\n\n    @Override\n    public void close() {\n        mBackupItem.cleanup();\n    }\n\n    @NonNull\n    public BackupMetadataV5 getMetadata() {\n        return mMetadata;\n    }\n\n    void runBackup(@Nullable ProgressHandler progressHandler) throws BackupException {\n        try {\n            // Fail backup if the app has items in Android KeyStore and backup isn't enabled\n            if (mBackupFlags.backupData() && mMetadata.metadata.keyStore && !Prefs.BackupRestore.backupAppsWithKeyStore()) {\n                throw new BackupException(\"The app has keystore items and KeyStore backup isn't enabled.\");\n            }\n            incrementProgress(progressHandler);\n            // Backup icon\n            backupIcon();\n            // Backup source\n            if (mBackupFlags.backupApkFiles()) {\n                backupApkFiles();\n                incrementProgress(progressHandler);\n            }\n            // Backup data\n            if (mBackupFlags.backupData()) {\n                backupData();\n                // Backup KeyStore\n                if (mMetadata.metadata.keyStore) {\n                    backupKeyStore();\n                }\n                incrementProgress(progressHandler);\n            }","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupOp.java#L139-L175","documentation":"BackupOp deliberately aborts the backup when the target app has entries in the Android KeyStore but the user has not enabled 'backup apps with keystore' in preferences. KeyStore entries cannot be captured in a normal data backup, so proceeding would produce an incomplete/restorable-failing backup. This is a preflight validation failure, not an I/O error.","triggerScenarios":"mBackupFlags.backupData() is requested, metadata.keyStore is true (app stores secrets in Android KeyStore), and Prefs.BackupRestore.backupAppsWithKeyStore() returns false when runBackup() executes.","commonSituations":"Backing up apps like messengers or authenticators that store keys in the system KeyStore without enabling the keystore-backup setting; running batch backups where most apps don't need the flag but some do.","solutions":["Enable the 'Backup apps with keystore' option in App Manager's backup/restore settings (Prefs.BackupRestore.backupAppsWithKeyStore).","Run the backup with root access, as keystore backup requires privileged access.","Exclude this app from keystore-flagged batch backups if its KeyStore contents are not needed.","Back up data without the data flag (backup only APK files) to avoid the keystore requirement."],"exampleFix":"// before\nBackupFlags flags = new BackupFlags(BackupFlags.BACKUP_DATA);\nnew BackupOp(context, packageInfo, flags).runBackup(progressHandler);\n// after\nif (metadata.keyStore && !Prefs.BackupRestore.backupAppsWithKeyStore()) {\n    Prefs.BackupRestore.setBackupAppsWithKeyStore(true); // or skip the app\n}\nnew BackupOp(context, packageInfo, flags).runBackup(progressHandler);","handlingStrategy":"validation","validationCode":"if (metadata.keyStore && mBackupFlags.backupData() && !Prefs.BackupRestore.backupAppsWithKeyStore()) {\n    // enable the setting or skip this app before calling runBackup()\n}","typeGuard":"boolean keystoreBackupAllowed(BackupMetadata meta) { return !meta.keyStore || Prefs.BackupRestore.backupAppsWithKeyStore(); }","tryCatchPattern":"try {\n    backupOp.runBackup(progress);\n} catch (BackupException e) {\n    if (e.getMessage().contains(\"keystore\")) { promptUserToEnableKeystoreBackup(); }\n}","preventionTips":["Enable 'Backup apps with keystore' before batch backups.","Skip or special-case apps flagged with keyStore in metadata.","Filter batch backup lists on metadata.keyStore when the setting is off.","Ensure root access — keystore backup silently fails configuration without it."],"tags":["android","backup","keystore","configuration"],"backgroundTag":"feature-not-enabled","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"}