MuntashirAkon/AppManager · error · KeyStoreException

Alias app_manager does not exist in KeyStore.

Error message

Alias app_manager does not exist in KeyStore.

What it means

Signer.getInstance looks up the app's internal signing key pair (alias SIGNING_KEY_ALIAS, e.g. app_manager) in App Manager's KeyStore-backed KeyStoreManager. If getKeyPair returns null the alias is absent, and the resulting KeyStoreException is wrapped in a SignatureException.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/apk/signing/Signer.java:55

    public static final String SIGNING_KEY_ALIAS = "signing_key";

    public static boolean canSign() {
        try {
            // In order to sign an APK, a signing key must be inserted
            return KeyStoreManager.getInstance().containsKey(Signer.SIGNING_KEY_ALIAS);
        } catch (Exception e) {
            // Signing not configured
            return false;
        }
    }

    @NonNull
    public static Signer getInstance(SigSchemes sigSchemes) throws SignatureException {
        try {
            KeyStoreManager manager = KeyStoreManager.getInstance();
            KeyPair signingKey = manager.getKeyPair(SIGNING_KEY_ALIAS);
            if (signingKey == null) {
                throw new KeyStoreException("Alias " + SIGNING_KEY_ALIAS + " does not exist in KeyStore.");
            }
            return new Signer(sigSchemes, signingKey.getPrivateKey(), (X509Certificate) signingKey.getCertificate());
        } catch (Exception e) {
            throw new SignatureException(e);
        }
    }

    @NonNull
    private final PrivateKey mPrivateKey;
    @NonNull
    private final X509Certificate mCertificate;
    @NonNull
    private final SigSchemes mSigSchemes;
    @Nullable
    private File mIdsigFile;

    private Signer(@NonNull SigSchemes sigSchemes, @NonNull PrivateKey privateKey, @NonNull X509Certificate certificate) {
        mSigSchemes = sigSchemes;

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Generate/import the signing key under alias app_manager via KeyStoreManager before signing
  2. Initialize/repair App Manager's key store (regenerate the default signing key)
  3. Catch SignatureException and prompt the user to set up signing keys first
  4. Verify alias existence with KeyStoreManager.getKeyPair(alias) != null before calling Signer.getInstance

Example fix

// before
Signer signer = Signer.getInstance(SigSchemes.V2);
// after
if (KeyStoreManager.getInstance().getKeyPair("app_manager") == null) {
    KeyStoreManager.getInstance().generateKeyPair("app_manager"); // or surface a setup UI
}
Signer signer = Signer.getInstance(SigSchemes.V2);
Defensive patterns

Strategy: validation

Validate before calling

KeyPair key = KeyStoreManager.getInstance().getKeyPair(SIGNING_KEY_ALIAS);
if (key == null) {
    // generate or import the signing key before calling Signer.getInstance
}

Type guard

boolean signingKeyAvailable() {
    try { return KeyStoreManager.getInstance().getKeyPair("app_manager") != null; }
    catch (Exception e) { return false; }
}

Prevention

When it happens

Trigger: Calling Signer.getInstance(sigSchemes) before the signing key with alias app_manager has been generated/imported into the KeyStore, or after it was deleted/key store reset.

Common situations: Fresh install where key generation never ran, clearing app data wiping the key store, device migration without the key, calling signing APIs without initializing credentials first.

Related errors


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