Alpha 版本的 APK 上传失败。来自 apksigner 的错误: API 级别 [[16, 17]] 不支持的摘要算法和签名算法

APK upload failed for Alpha version. Errors from apksigner: Digest algorithm and Signature Algorithm Which is not supported on API levels [[16, 17]]

我已经使用 keytool、jarsigner 和 zipalign 实用程序对 APK 进行了签名。

我使用了以下命令:

keytool -genkey -v -keystore myAppTransporterKey.keystore -alias myTransporter -keyalg RSA -keysize 2048 -validity 10000

cordova 插件 rm cordova-plugin-console

cordova build --release android

jarsigner -verbose -keystore C:\Users\ali\Documents\transporterApp\myAppKey.keystore C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\android-release-unsigned.apk myTransporter


jarsigner -verify C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\android-release-unsigned.apk

运行之后:

jarsigner -verify -verbose -certs C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\android-release-unsigned.apk

收到此消息:jar 已验证

运行之后:

zipalign -v 4 C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\android-release-unsigned.apk C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\myTransporter-Final.apk

收到消息:验证成功

在 Google 播放控制台中上传到 ALPAH 后 我收到以下错误

Upload new APK to Alpha

Uploading

You have uploaded an APK with an invalid signature ( read more about signing ). Errors from apksigner: ERROR (Jar signer D2DTRANS.RSA): JAR signature META-INF / D2DTRANS.RSA uses digest algorithm 2.16.840.1.101.3.4.2.1 and Signature Algorithm 1.2.840.113549.1.1.1 Which is not supported on API levels [[16, 17]]

您需要这些步骤:

1) jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore C:\Users\ali\Documents\transporterApp\myAppKey.keystore C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\android-release-unsigned.apk myTransporter

2) jarsigner -verify C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\android-release-unsigned.apk

3) zipalign -v 4 C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\android-release-unsigned.apk C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\myTransporter-Final.apk

希望对您有所帮助^^

您需要执行以下步骤:

zipalign -v 4 C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\android-release-unsigned.apk C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\android-release-unsigned-aligned.apk

apksigner sign --ks C:\Users\ali\Documents\transporterApp\myAppKey.keystore --ks-pass pass:[PASSWORD] --key-pass pass:[PASSWORD] --out C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\android-release-singned.apk C:\Users\ali\Documents\transporterApp\platforms\android\build\outputs\apk\android-release-unsigned-aligned.apk

要签署应用程序,请使用 BuildTools 24.0.3

https://developer.android.com/studio/releases/build-tools.html

根据official documentation,您可以执行以下步骤:

  1. 生成 .apk 文件
  2. 对齐数据:zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk
  3. 签署 APK:apksigner sign --ks my-release-key.jks --out my-app-release.apk my-app-unsigned-aligned.apk

您可能需要使用 --ks-type 选项定义密钥库的类型:

~/Android/Sdk/build-tools/26.0.2/apksigner sign --ks-type pkcs12 --ks ~/[…].p12 \
--out android-release-signed-aligned.apk android-release-unsigned-aligned.apk

这已在 apksigner 0.8 中修复,已在 Android 中发布SDK 构建工具 26.0.2.

如果任何问题仍然存在,请报告 Google issue tracker 他们将重新开放进行检查。