MuntashirAkon/AppManager · error · BackupException
Rules restore is requested but the app isn't installed.
Error message
Rules restore is requested but the app isn't installed.
What it means
Thrown by restoreRules when a rules restore was requested but the target application is not installed. AppManager's rules (component blocking etc.) are stored via the system for an installed package, so applying rules to a missing package is rejected up front.
Solutions
- Install the application first, then re-run the restore with rules enabled
- Disable the rules-restore flag in the restore options
- Verify the target userId matches the profile where the app is installed
- Restore rules manually via AppManager's rules UI after installing the app
Example fix
// before
new RestoreOp(context, backupItem, new RestoreRequestFlags(/* rules */ true, ...)).runRestore();
// after
if (isPackageInstalled(context, pkg, userId)) {
new RestoreOp(context, backupItem, new RestoreRequestFlags(true, ...)).runRestore();
} else {
Log.w(TAG, "App not installed; skipping rules restore");
} Defensive patterns
Strategy: validation
Validate before calling
try {
context.getPackageManager().getPackageInfoForUser(pkg, 0, userId);
} catch (PackageManager.NameNotFoundException e) {
flags.restoreRules = false;
} Try / catch
try {
restoreOp.runRestore();
} catch (BackupException e) {
if (e.getMessage().contains("app isn't installed")) {
queueRulesRestoreAfterInstall();
} else throw e;
} Prevention
- Install the app before any restore that includes rules
- Match the restore target user to where the app is installed
- Split restores into install → data → rules steps
When it happens
Trigger: Backup flags request rules restore but mIsInstalled is false when restoreRules runs — package absent for the given user at restore time.
Common situations: Restoring rules for an uninstalled app; wrong user profile (app installed on user 0 but restore targets user 10); full restore attempted after app was uninstalled following backup creation.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Misc restore is requested but the app isn't installed.
- Rules file is missing.
- ADB restore is requested but there are no .ab files.
- An uninstallation was necessary but couldn't perform it.
- Android System (android) cannot be backed up.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/062cd765e859bccc.
Report an issue: GitHub.
Appendix: source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java:755
}
}
// Decrypt permission file
try {
miscFile = mBackupItem.decrypt(new Path[]{miscFile})[0];
} catch (IOException | IndexOutOfBoundsException e) {
throw new BackupException("Failed to decrypt " + miscFile.getName(), e);
}
try {
rules.loadExternalEntries(miscFile);
} catch (Throwable e) {
throw new BackupException("Failed to load rules from misc.", e);
}
}
private void restoreRules() throws BackupException {
// Apply rules
if (!mIsInstalled) {
throw new BackupException("Rules restore is requested but the app isn't installed.");
}
Path rulesFile;
try {
rulesFile = mBackupItem.getRulesFile();
} catch (IOException e) {
if (mBackupMetadata.hasRules) {
throw new BackupException("Rules file is missing.", e);
} else {
// There are no rules, just skip
return;
}
}
if (!mRequestedFlags.skipSignatureCheck()) {
String checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, rulesFile);
if (!checksum.equals(mChecksum.get(rulesFile.getName()))) {
throw new BackupException("Couldn't verify permission file." +
"\nFile: " + rulesFile +
"\nFound: " + checksum +View on GitHub (pinned to 0152f468fc)