shwenzhang/AndResGuard · error · java.io.IOException

Can't Generate signed APK v2. Plz check your v2sign info is…

Error message

Can't Generate signed APK v2. Plz check your v2sign info is correct.

What it means

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.

Solutions

  1. Check the log above this exception for the apksigner error output (e.g. 'Keystore was tampered with, or password was incorrect')
  2. Verify the v2sign config: keystore file path exists, storePass, keyAlias, and keyPass are correct
  3. Confirm minSDKVersion is >= 24 for v3 signing or switch signatureType to SchemaV2
  4. Run apksigner sign manually with the same parameters to see the full error
Defensive patterns

Strategy: validation

Validate before calling

File ks = new File(storeFilePath);
if (!ks.isFile()) throw new IllegalStateException("keystore not found: " + ks);
try {
  KeyStore k = KeyStore.getInstance("PKCS12");
  k.load(new FileInputStream(ks), storePass.toCharArray());
  if (!k.isKeyEntry(alias)) throw new IllegalStateException("alias not a key entry: " + alias);
} catch (Exception e) { throw new IllegalStateException("v2sign config invalid: " + e.getMessage(), e); }
if (signatureType == SchemaV3 && minSdkVersion < 24)
  throw new IllegalStateException("v3 signing requires minSdkVersion >= 24");

Try / catch

try {
  andResGuard.build();
} catch (IOException e) {
  if (e.getMessage().contains("Can't Generate signed APK v2")) {
    throw new IllegalStateException("apksigner failed — verify keystore path, storePass, keyAlias, keyPass and minSdkVersion; see apksigner output above", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12). Data as JSON: /api/errors/e2079db686fcb607. Report an issue: GitHub.

Appendix: source

Thrown at AndResGuard-core/src/main/java/com/tencent/mm/androlib/ResourceApkBuilder.java:214

  private void signApkV1(File unSignedApk, File signedApk) throws IOException, InterruptedException {
    if (config.mUseSignAPK) {
      System.out.printf("signing apk: %s\n", signedApk.getName());
      if (signedApk.exists()) {
        signedApk.delete();
      }
      signWithV1sign(unSignedApk, signedApk);
      if (!signedApk.exists()) {
        throw new IOException("Can't Generate signed APK. Plz check your v1sign info is correct.");
      }
    }
  }

  private void signApkV2V3(File unSignedApk, File signedApk, int minSDKVersion, InputParam.SignatureType signatureType) throws Exception {
    if (config.mUseSignAPK) {
      System.out.printf("signing apk: %s\n", signedApk.getName());
      signWithV2V3Sign(unSignedApk, signedApk, minSDKVersion, signatureType);
      if (!signedApk.exists()) {
        throw new IOException("Can't Generate signed APK v2. Plz check your v2sign info is correct.");
      }
    }
  }

  private void signWithV2V3Sign(File unSignedApk, File signedApk, int minSDKVersion, InputParam.SignatureType signatureType) throws Exception {
    String[] params = new String[] {
        "sign",
        "--ks",
        config.mSignatureFile.getAbsolutePath(),
        "--ks-pass",
        "pass:" + config.mStorePass,
        "--min-sdk-version",
        String.valueOf(minSDKVersion),
        "--ks-key-alias",
        config.mStoreAlias,
        "--key-pass",
        "pass:" + config.mKeyPass,
        "--v3-signing-enabled",

View on GitHub (pinned to e4df245d82)