更新后生成签名 APK Android Studio

Generate signed APK after update Android Studio

我遇到了很奇怪的问题。几年前,我写了一个用 Eclipse 编写的应用程序。然后我升级到 Android Studio 0.4.3 一切正常,但现在我删除了这个 AS 并使用新版本 (Android Studio 141.xxxx)。

The problem is, that I use the same JKS certificate, but after upload to Google Play Store I see communicate about difference in finger print.

You uploaded an APK that is signed with a different certificate to your previous APKs. You must use the same certificate. Your existing APKs are signed with the certificate(s) with fingerprint(s):

[ SHA1: D0:D9:BE:8B:D2:6A:5F:xxxxxxxxxxxxxxxxxxxx:F4:D9:91:66:06:12 ]

and the certificate(s) used to sign the APK you uploaded have fingerprint(s):

[ SHA1: DA:53:9F:A7:D3:3C:8D:xxxxxxxxxxxxxxxxxxxx:CE:1F:F2:AB:0B:64 ]

我尝试在我的应用程序手册上签名,但后来我收到了这个通知。

Upload failed You uploaded an APK with invalid or missing signing information for some of its files. You need to create a valid signed APK. Learn more about signing.

有人有想法吗? Here 是类似的问题,但没有答案。

我认为您遇到的问题是您在上传 apk 时没有使用自己的密钥库文件。 该文件可能在 IDE 个版本之间发生了变化。

请参阅此答案以了解为什么会出现此问题:

另请阅读此参考页以了解如何正确签署您的 apk https://developer.android.com/tools/publishing/app-signing.html

祝你好运

可能是密钥库有问题。

You uploaded an APK that is signed with a different certificate to your previous APKs. You must use the same certificate. Your existing APKs are signed with the certificate(s) with fingerprint(s):

[ SHA1: D0:D9:BE:8B:D2:6A:5F:xxxxxxxxxxxxxxxxxxxx:F4:D9:91:66:06:12 ]

and the certificate(s) used to sign the APK you uploaded have fingerprint(s):

[ SHA1: DA:53:9F:A7:D3:3C:8D:xxxxxxxxxxxxxxxxxxxx:CE:1F:F2:AB:0B:64 ]

这意味着您使用了不正确的密钥库,而不是您用于签署先前版本 APK 的密钥库。

确保您使用相同的密钥库文件。如果相同 - 再次重新生成密钥。

好的...我终于解决了这个问题。但我仍然不知道它为什么会发生。

首先我要确保我之前使用的是相同的jks

jarsigner -verify -verbose:summary -certs old.apk
jarsigner -verify -verbose:summary -certs new.apk

证书看起来一样。因此,我构建了我的应用程序并使用我的证书对其进行了签名。但它不起作用。

所以我手动做了

  1. 我用 WinRAR 打开我的 apk 文件,然后从 app-release-unaligned.apk (app\build\outputs\apk 在我的例子中)
  2. 将 zipalign.exe 粘贴到我的应用程序发布文件夹 -unaligned.apk
  3. 在包含您的 apk 的文件夹中打开 CMD (shift + 右键单击​​ + "Open command window here.")

然后我手动使用jarsigner然后zipalign.exe

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore key.jks -storepass MYPASSWORD app-release-unaligned.apk 1

zipalign -f -v 4 app-release-unaligned.apk app-release.apk

然后我将 app-release.apk 上传到 Google 控制台。一切都很好 ;)