MuntashirAkon/AppManager · error · BackupException

Backup is requested without any flags.

Error message

Backup is requested without any flags.

What it means

BackupManager requires at least one backup flag (what to back up: APK, data, permissions, etc.). An empty flag set gives the backup engine nothing to do, so it rejects the request up front with BackupException.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupManager.java:68

    }

    private boolean mRequiresRestart;

    public BackupManager() {
        ExUtils.exceptionAsIgnored(BackupItems::createNoMediaIfNotExists);
    }

    public boolean requiresRestart() {
        return mRequiresRestart;
    }

    public void backup(@NonNull BackupOpOptions options, @Nullable ProgressHandler progressHandler)
            throws BackupException {
        if (options.packageName.equals("android")) {
            throw new BackupException("Android System (android) cannot be backed up.");
        }
        if (options.flags.isEmpty()) {
            throw new BackupException("Backup is requested without any flags.");
        }
        BackupItems.BackupItem backupItem;
        try {
            if (options.override) {
                backupItem = BackupItems.findOrCreateBackupItem(options.userId, options.backupName, options.packageName);
            } else {
                backupItem = BackupItems.createBackupItemGracefully(options.userId, options.backupName, options.packageName);
            }
        } catch (IOException e) {
            throw new BackupException("Could not create BackupItem.", e);
        }
        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);

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Set at least one flag (e.g. BACKUP_APK or BACKUP_DATA) in BackupOpOptions before calling backup
  2. Validate flag selection in UI before starting the backup
  3. Catch BackupException and inform the user to choose what to back up
  4. Provide sensible default flags when constructing options

Example fix

// before
BackupOpOptions options = new BackupOpOptions(pkg, new ArrayList<>(), false, userId);
backupManager.backup(options, null); // throws
// after
List<Integer> flags = Collections.singletonList(BackupFlags.BACKUP_APK | BackupFlags.BACKUP_DATA);
BackupOpOptions options = new BackupOpOptions(pkg, flags, false, userId);
backupManager.backup(options, null);
Defensive patterns

Strategy: validation

Validate before calling

if (options.flags.isEmpty()) {
    throw new IllegalArgumentException("Select at least one backup flag before starting");
}

Prevention

When it happens

Trigger: Calling BackupManager.backup with BackupOpOptions whose flags collection is empty — constructing options without selecting any of the backup mode flags.

Common situations: Programmatic/automation callers building options from user UI where no checkbox was ticked, defaults lost after a refactor, flags cleared before the call.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


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