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 sources

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Restore/install the app first so mPackageInfo is populated, then retry KeyStore restore.
  2. Uncheck the KeyStore option if you only want data restore without keystore files.
  3. On Android 12+ note keystore backup/restore is skipped entirely (v2 unsupported).
  4. 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

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


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