MuntashirAkon/AppManager · error · BackupException
KeyStore restore is requested but the app isn't installed.
Error message
KeyStore restore is requested but the app isn't installed.
What it means
restoreKeyStore restores app key store files, but only if the app is installed (mPackageInfo != null). On Android < S, if the package info was never populated (app not installed/restored), AppManager refuses to restore KeyStore data and throws this error, because keystores belong to a UID that must exist.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java:418
try {
mPackageInfo = PackageManagerCompat.getPackageInfo(mPackageName, GET_SIGNING_CERTIFICATES
| PackageManagerCompat.MATCH_STATIC_SHARED_AND_SDK_LIBRARIES, mUserId);
mUid = Objects.requireNonNull(mPackageInfo.applicationInfo).uid;
mIsInstalled = true;
} catch (Exception e) {
throw new BackupException("Apparently the install wasn't complete in the previous section.", e);
}
}
}
private void restoreKeyStore() throws BackupException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// keystore v2 is not supported.
Log.w(TAG, "Ignoring KeyStore backups for %s", mPackageName);
return;
}
if (mPackageInfo == null) {
throw new BackupException("KeyStore restore is requested but the app isn't installed.");
}
Path[] keyStoreFiles = mBackupItem.getKeyStoreFiles();
if (keyStoreFiles.length == 0) {
throw new BackupException("KeyStore files should've existed but they didn't");
}
if (!mRequestedFlags.skipSignatureCheck()) {
String checksum;
for (Path file : keyStoreFiles) {
checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, file);
if (!checksum.equals(mChecksum.get(file.getName()))) {
throw new BackupException("KeyStore file verification failed." +
"\nFile: " + file +
"\nFound: " + checksum +
"\nRequired: " + mChecksum.get(file.getName()));
}
}
}
// Decrypt sourcesView on GitHub (pinned to 0152f468fc)
Solutions
- Restore/install the app first so mPackageInfo is populated, then retry KeyStore restore.
- Uncheck the KeyStore option if you only want data restore without keystore files.
- On Android 12+ note keystore backup/restore is skipped entirely (v2 unsupported).
- Fix earlier restore failures (installation errors) before attempting keystore restore.
Example fix
// before
restoreKeyStore();
// after
if (mPackageInfo != null) {
restoreKeyStore();
} else {
Log.w(TAG, "Skipping KeyStore restore: app not installed");
} Defensive patterns
Strategy: type-guard
Validate before calling
if (mPackageInfo == null || !mIsInstalled) skipKeyStoreRestore();
Type guard
boolean canRestoreKeyStore(PackageInfo pi) { return pi != null && pi.applicationInfo != null; } Try / catch
if (mPackageInfo == null) { throw new BackupException("KeyStore restore is requested but the app isn't installed."); } // callers: catch BackupException and skip keystore step gracefully Prevention
- Always install the app before requesting KeyStore restore
- Check the requested flags match what the backup actually contains
- Handle Android 12+ where keystore restore is unsupported
- Surface keystore-skip as a warning instead of failing the whole restore
When it happens
Trigger: restoreKeyStore is invoked with mPackageInfo == null: KeyStore restore was requested in flags but the app was not installed (restoreData/restoreApk failed or was skipped, or the app simply is not present on the device).
Common situations: Restoring only KeyStore without restoring the app; the APK install step failed earlier; running on Android < 12 where keystore v1 restore requires an installed app; users disabled/blocked the app before restore.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Alias app_manager does not exist in KeyStore.
- Failed to setup metadata.
- The app has keystore items and KeyStore backup isn't enabled
- Master key existed when the checksum was made but now it doe
- Master key exists but it didn't exist when the backup was ma
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/d709e9909a3ed534.
Report an issue: GitHub.