{"record":{"id":"5c0b3c1d373c1a07","repo":"MuntashirAkon/AppManager","slug":"failed-to-sign","errorCode":null,"errorMessage":"Failed to sign ","messagePattern":"Failed to sign ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/apk/ApkFile.java","lineNumber":742,"sourceCode":"         * @throws IOException If the APK cannot be signed or cached.\n         */\n        private File getSignedFile() throws IOException {\n            File realFile = getRealCachedFile();\n            if (Paths.exists(mSignedFile)) return mSignedFile;\n            mSignedFile = mFileCache.createCachedFile(\"apk\");\n            SigSchemes sigSchemes = Prefs.Signing.getSigSchemes();\n            boolean zipAlign = Prefs.Signing.zipAlign();\n            try {\n                Signer signer = Signer.getInstance(sigSchemes);\n                if (signer.isV4SchemeEnabled()) {\n                    mIdsigFile = mFileCache.createCachedFile(\"idsig\");\n                    signer.setIdsigFile(mIdsigFile);\n                }\n                if (signer.sign(realFile, mSignedFile, -1, zipAlign)\n                        && Signer.verify(sigSchemes, mSignedFile, mIdsigFile)) {\n                    return mSignedFile;\n                }\n                throw new IOException(\"Failed to sign \" + realFile);\n            } catch (IOException e) {\n                throw e;\n            } catch (Exception e) {\n                throw new IOException(e);\n            }\n        }\n\n        /**\n         * Same as {@link #getSignedFile()} except that it returns an {@link InputStream}.\n         *\n         * @throws IOException If the APK cannot be signed or cached.\n         */\n        private InputStream getSignedInputStream() throws IOException {\n            return new FileInputStream(getSignedFile());\n        }\n\n        /**\n         * Get the APK file source if it has a physical location.","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/apk/ApkFile.java#L724-L760","documentation":"ApkFile throws this IOException when the apksig Signer.sign() call fails or the signature verification via Signer.verify() returns false after producing the signed APK file. The original cause (a nested Exception) is wrapped as the IOException cause when sign() itself threw.","triggerScenarios":"Calling ApkFile.withSignature(...) / sign flow where signer.sign(realFile, mSignedFile, -1, zipAlign) returns false, or Signer.verify(sigSchemes, mIdsigFile) returns false, or sign() throws a non-IOException (wrapped by catch (Exception e)).","commonSituations":"Corrupt or already-signed input APK, invalid/missing keystore or signing key, unsupported signature schemes requested (e.g. v4 without idsig file), disk full while writing mSignedFile, or zipAlign failing on a malformed APK.","solutions":["Read the wrapped cause exception to find whether signing or verification failed","Verify the keystore/alias/password and that the signing key is valid and readable","Check free disk space for the output signed file","Ensure requested signature schemes match the provided files (e.g. provide an idsig file for v4 scheme)","Test the input APK opens as a valid ZIP before signing"],"exampleFix":"// before\nthrow new IOException(\"Failed to sign \" + realFile);\n// after\nthrow new IOException(\"Failed to sign \" + realFile + \"; verify signing key and input APK validity\", e);","handlingStrategy":"try-catch","validationCode":"// before signing\nif (!realFile.canRead() || realFile.length() == 0) throw new IllegalArgumentException(\"Input APK unreadable/empty\");\nif (new File(mSignedFile.getPath()).getUsableSpace() < realFile.length() * 2L) throw new IOException(\"Not enough disk space\");","typeGuard":null,"tryCatchPattern":"try {\n    File signed = apkFile.sign();\n} catch (IOException e) {\n    // inspect e.getCause(): signing failure vs verification failure\n    Log.e(TAG, \"APK signing failed\", e);\n}","preventionTips":["Validate the input APK is a readable ZIP before signing","Confirm keystore, alias, and passwords are correct and key is not expired","Match requested signature schemes to available artifacts (v4 needs an idsig file)","Keep sufficient free disk space for the signed output"],"tags":["apk-signing","io"],"backgroundTag":"file-write-failed","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"}