packer-ng-plugin
packer-ng-plugin copied to clipboard
return code: 1, stderr: Error: Invalid Signature: xxx.apk
当设置应用minSdkVersion>=24时,输出渠道包失败,提示 return code: 1, stderr: Error: Invalid Signature: xxx.apk 原因是:ApkVerifier验证签名时,从Android N开始,不需要验证V1签名,如下代码: private Result verify(DataSource apk) { ······ // Attempt to verify the APK using JAR signing if necessary. Platforms prior to Android N // ignore APK Signature Scheme v2 signatures and always attempt to verify JAR signatures. // Android N onwards verifies JAR signatures only if no APK Signature Scheme v2 (or newer // scheme) signatures were found. if ((minSdkVersion < AndroidSdkVersion.N) || (foundApkSigSchemeIds.isEmpty())) { V1SchemeVerifier.Result v1Result = V1SchemeVerifier.verify( apk, zipSections, SUPPORTED_APK_SIG_SCHEME_NAMES, foundApkSigSchemeIds, minSdkVersion, maxSdkVersion); result.mergeFrom(v1Result); } ······ } 而generate命令执行验证apk签名时,未区分平台版本,如下 代码: public static boolean verifyApk(File file) throws IOException { ApkVerifier verifier = new Builder(file).build(); try { Result result = verifier.verify(); return result.isVerified() && result.isVerifiedUsingV1Scheme() && result.isVerifiedUsingV2Scheme(); } catch (ApkFormatException e) { throw new IOException(e); } catch (NoSuchAlgorithmException e) { throw new IOException(e); } }