android - 由于证书不同,无法将更新的 APK 上传到 Google Play

标签 android google-play apk

我正在使用 Android Studio 来构建我的 Android 项目,当我将我的 APK 上传到 Google Play 时,尽管使用了我之前使用的 same keystore,但它一直向我显示此错误我的应用版本:

Upload failed

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: 89:2F:11:FE:CE:D6:CC:DF:65:E7:76:3E:DD:A7:96:4F:84:DD:BA:33 ]
and the certificate(s) used to sign the APK you uploaded have fingerprint(s):
[ SHA1: 20:26:F4:C1:DF:0F:2B:D9:46:03:FF:AB:07:B1:28:7B:9C:75:44:CC ]

最佳答案

首先,Google Play 在这里不太可能出错。你确定你没有错误地使用你的调试 key 吗?

检查使用的签名 key

您应该使用以下命令仔细检查旧 APK 和新 APK 包含哪些证书:

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

这会向您显示有关每个 APK 中已签名文件的信息,如下所示:

sm  4642892 Thu Apr 17 10:57:44 CEST 2014 classes.dex (and 412 more)

    X.509, CN=My App, O=My Company, C=DE, L=Köln
    [certificate is valid from 11/11/13 12:12 to 29/03/41 12:12]
    [CertPath not validated: Path does not chain with any of the trust anchors]

如果新 APK 显示 X.509, CN=Android Debug, O=Android, C=US,则您已使用调试 key 而不是原始发布 key 签署 APK。

如果 X.509 身份字符串在其他方面不同,或者两个 APK 的证书日期不同,则您刚刚确认您没有对两个 APK 使用相同的签名 key 。

您可以忽略任何“CertPath 未验证”消息;在这种情况下它不相关。

搜索原始 keystore

如果证书信息不同,你需要找到原来的keystore,即Google Play告诉你的第一个SHA1值的文件。

搜索所有可以找到的 keystore 文件,直到找到具有正确 SHA1 指纹的文件:

keytool -list -keystore my-release.keystore

我找不到原来的 keystore

如果您找不到原始 keystore ,您将永远无法发布此特定应用的任何更新。

Android 在 Signing Your Application 上明确提到了这一点。页面:

Warning: Keep your keystore and private key in a safe and secure place, and ensure that you have secure backups of them. If you publish an app to Google Play and then lose the key with which you signed your app, you will not be able to publish any updates to your app, since you must always sign all versions of your app with the same key.

第一次发布 APK 后,所有后续版本都必须使用完全相同的 key 进行签名。

我可以从原始 APK 中提取原始签名 key 吗?

没有。这是不可能的。 APK 只包含公共(public)信息,不包含您的私钥信息。

我可以迁移到新的签名 key 吗?

没有。即使您确实找到了原始版本,也不能使用 key A 签署 APK,然后使用 key A 和 B 签署下一个更新,然后仅使用 key B 签署下一个更新。

技术上可以使用多个 key 对 APK(或任何 JAR 文件)进行签名,但 Google Play 不接受具有多个签名的 APK。

我能做什么?

您必须使用新的应用程序 ID 构建您的应用程序(例如,从“com.example.myapp”更改为“com.example.myapp2”)并在 Google Play 上创建一个全新的列表。

您可能还必须更改代码,以便人们可以安装新应用,即使他们安装了旧应用,例如您需要确保没有冲突的内容提供者。

您将失去现有的安装基础、评论等,并且必须想办法让现有客户卸载旧应用并安装新版本。

再次确保您备份了用于此版本的 keystore 和密码。

关于android - 由于证书不同,无法将更新的 APK 上传到 Google Play,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26288234/

相关文章:

java - Android:登出系统和android生命周期

java - 尝试从本地文件而不是网站加载应用程序

android - 在类中调用 View 模型

android - 应用程序与 Nexus 7 和 Acer Iconia a210 不兼容

android - 安全警报 : App contains embedded private keys or keystore files

android - 为什么Android允许安装证书过期的APK?

android - 如何从Edittext中获取文字为图片命名

安卓市场不兼容

android - 我的文件下载器突然出现错误

java - 将未签名的 apk 转换为已签名的 apk