{"record":{"id":"e2079db686fcb607","repo":"shwenzhang/AndResGuard","slug":"can-t-generate-signed-apk-v2-plz-check-your-v2sign-info-is","errorCode":null,"errorMessage":"Can't Generate signed APK v2. Plz check your v2sign info is correct.","messagePattern":"Can't Generate signed APK v2\\. Plz check your v2sign info is correct\\.","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/com/tencent/mm/androlib/ResourceApkBuilder.java","lineNumber":214,"sourceCode":"  private void signApkV1(File unSignedApk, File signedApk) throws IOException, InterruptedException {\n    if (config.mUseSignAPK) {\n      System.out.printf(\"signing apk: %s\\n\", signedApk.getName());\n      if (signedApk.exists()) {\n        signedApk.delete();\n      }\n      signWithV1sign(unSignedApk, signedApk);\n      if (!signedApk.exists()) {\n        throw new IOException(\"Can't Generate signed APK. Plz check your v1sign info is correct.\");\n      }\n    }\n  }\n\n  private void signApkV2V3(File unSignedApk, File signedApk, int minSDKVersion, InputParam.SignatureType signatureType) throws Exception {\n    if (config.mUseSignAPK) {\n      System.out.printf(\"signing apk: %s\\n\", signedApk.getName());\n      signWithV2V3Sign(unSignedApk, signedApk, minSDKVersion, signatureType);\n      if (!signedApk.exists()) {\n        throw new IOException(\"Can't Generate signed APK v2. Plz check your v2sign info is correct.\");\n      }\n    }\n  }\n\n  private void signWithV2V3Sign(File unSignedApk, File signedApk, int minSDKVersion, InputParam.SignatureType signatureType) throws Exception {\n    String[] params = new String[] {\n        \"sign\",\n        \"--ks\",\n        config.mSignatureFile.getAbsolutePath(),\n        \"--ks-pass\",\n        \"pass:\" + config.mStorePass,\n        \"--min-sdk-version\",\n        String.valueOf(minSDKVersion),\n        \"--ks-key-alias\",\n        config.mStoreAlias,\n        \"--key-pass\",\n        \"pass:\" + config.mKeyPass,\n        \"--v3-signing-enabled\",","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/com/tencent/mm/androlib/ResourceApkBuilder.java#L196-L232","documentation":"signApkV2V3 invokes ApkSignerTool to produce a v2/v3-signed APK, then throws this IOException if the output file does not exist — meaning apksigner failed silently (its errors go to the log, not the exception). Common causes are wrong keystore credentials, keystore file missing, or an invalid minSdkVersion/signatureType combination.","triggerScenarios":"buildApkWithV2V3Sign -> signApkV2V3 with config.mUseSignAPK=true when ApkSignerTool.main throws or writes no output: bad --ks/--ks-pass/--ks-key-alias/--key-pass values, unreadable keystore, or apksigner library rejecting the APK.","commonSituations":"Migrating from v1 to v2 signing without updating storePassword/keyAlias; keystore path relative to the wrong working directory on CI; using SignatureType SchemaV3 with a minSdkVersion below what v3 supports; corrupted or non-PKCS12 keystore.","solutions":["Check the log above this exception for the apksigner error output (e.g. 'Keystore was tampered with, or password was incorrect')","Verify the v2sign config: keystore file path exists, storePass, keyAlias, and keyPass are correct","Confirm minSDKVersion is >= 24 for v3 signing or switch signatureType to SchemaV2","Run apksigner sign manually with the same parameters to see the full error"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"File ks = new File(storeFilePath);\nif (!ks.isFile()) throw new IllegalStateException(\"keystore not found: \" + ks);\ntry {\n  KeyStore k = KeyStore.getInstance(\"PKCS12\");\n  k.load(new FileInputStream(ks), storePass.toCharArray());\n  if (!k.isKeyEntry(alias)) throw new IllegalStateException(\"alias not a key entry: \" + alias);\n} catch (Exception e) { throw new IllegalStateException(\"v2sign config invalid: \" + e.getMessage(), e); }\nif (signatureType == SchemaV3 && minSdkVersion < 24)\n  throw new IllegalStateException(\"v3 signing requires minSdkVersion >= 24\");","typeGuard":null,"tryCatchPattern":"try {\n  andResGuard.build();\n} catch (IOException e) {\n  if (e.getMessage().contains(\"Can't Generate signed APK v2\")) {\n    throw new IllegalStateException(\"apksigner failed — verify keystore path, storePass, keyAlias, keyPass and minSdkVersion; see apksigner output above\", e);\n  }\n  throw e;\n}","preventionTips":["Use apksigner verify/ sign manually once to validate the keystore before automating","Match signatureType (SchemaV2 vs SchemaV3) to your minSdkVersion","Use absolute paths for the keystore to avoid CI working-directory surprises","Check the apksigner output in the log — this exception masks the real failure"],"tags":["java","signing","apksigner","apk","io"],"backgroundTag":"file-not-found","analyzedSha":"e4df245d82f27d9a2d0dd108260a3510cbaba849","analyzedAt":"2026-09-12T17:49:07.798Z","contentChangedAt":"2026-09-12T17:49:07.798Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}