{"record":{"id":"e42754eba1a8f0a1","repo":"MuntashirAkon/AppManager","slug":"alias-app-manager-does-not-exist-in-keystore","errorCode":null,"errorMessage":"Alias app_manager does not exist in KeyStore.","messagePattern":"Alias app_manager does not exist in KeyStore\\.","errorType":"exception","errorClass":"KeyStoreException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/apk/signing/Signer.java","lineNumber":55,"sourceCode":"    public static final String SIGNING_KEY_ALIAS = \"signing_key\";\n\n    public static boolean canSign() {\n        try {\n            // In order to sign an APK, a signing key must be inserted\n            return KeyStoreManager.getInstance().containsKey(Signer.SIGNING_KEY_ALIAS);\n        } catch (Exception e) {\n            // Signing not configured\n            return false;\n        }\n    }\n\n    @NonNull\n    public static Signer getInstance(SigSchemes sigSchemes) throws SignatureException {\n        try {\n            KeyStoreManager manager = KeyStoreManager.getInstance();\n            KeyPair signingKey = manager.getKeyPair(SIGNING_KEY_ALIAS);\n            if (signingKey == null) {\n                throw new KeyStoreException(\"Alias \" + SIGNING_KEY_ALIAS + \" does not exist in KeyStore.\");\n            }\n            return new Signer(sigSchemes, signingKey.getPrivateKey(), (X509Certificate) signingKey.getCertificate());\n        } catch (Exception e) {\n            throw new SignatureException(e);\n        }\n    }\n\n    @NonNull\n    private final PrivateKey mPrivateKey;\n    @NonNull\n    private final X509Certificate mCertificate;\n    @NonNull\n    private final SigSchemes mSigSchemes;\n    @Nullable\n    private File mIdsigFile;\n\n    private Signer(@NonNull SigSchemes sigSchemes, @NonNull PrivateKey privateKey, @NonNull X509Certificate certificate) {\n        mSigSchemes = sigSchemes;","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/apk/signing/Signer.java#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Generate/import the signing key under alias app_manager via KeyStoreManager before signing","Initialize/repair App Manager's key store (regenerate the default signing key)","Catch SignatureException and prompt the user to set up signing keys first","Verify alias existence with KeyStoreManager.getKeyPair(alias) != null before calling Signer.getInstance"],"exampleFix":"// before\nSigner signer = Signer.getInstance(SigSchemes.V2);\n// after\nif (KeyStoreManager.getInstance().getKeyPair(\"app_manager\") == null) {\n    KeyStoreManager.getInstance().generateKeyPair(\"app_manager\"); // or surface a setup UI\n}\nSigner signer = Signer.getInstance(SigSchemes.V2);","handlingStrategy":"validation","validationCode":"KeyPair key = KeyStoreManager.getInstance().getKeyPair(SIGNING_KEY_ALIAS);\nif (key == null) {\n    // generate or import the signing key before calling Signer.getInstance\n}","typeGuard":"boolean signingKeyAvailable() {\n    try { return KeyStoreManager.getInstance().getKeyPair(\"app_manager\") != null; }\n    catch (Exception e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Initialize/generate the signing key on first app setup","Do not clear app data without re-creating keys","Check alias existence before every signing session"],"tags":["android","keystore","signing","missing-key"],"backgroundTag":"missing-credentials","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}