是否可以扩展用于签署 Android APK 的证书?

Is it possible to extend a certificate that was used in signing an Android APK?

出于测试目的,我们为我们的产品(不在 Google Play 商店中)创建了一个 APK,该 APK 使用现已过期的自签名证书进行签名。我通过使用相同的 public/private 密钥创建新证书来“更新”证书,但有效期为 10 年。

我们每次使用包含 public 和私钥的 PFX 文件都使用 keytool 重新创建密钥库,然后使用 apksigner 进行签名。

不幸的是,当在使用旧证书签名的 APK 之上安装使用包含扩展证书的新 PFX 文件签名的 APK 时,我们收到以下错误(全新安装没问题):

adb: failed to install MyTest.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.example.MyTest signatures do not match previously installed version; ignoring!]

主要问题:

辅助问题:

Does the INSTALL_FAILED_UPDATE_INCOMPATIBLE error depend on the value of the > public key (which is the same as before) or the signature of the public key > certificate (which has presumably changed because the expiry date has changed)?

是的。此信息不会显示在您的应用中,但会作为 APK 的一部分包含在您的证书中。

Q2:每次使用您的密钥更改包时都会对其进行签名,以识别它来自正确的来源 - 密钥未更改 - google play store 和 android OS将通过在数据上使用 key/certificate 和 运行 来检测内容是否已更改。如果包名称相同但签名不匹配,它将失败并给出此错误。

Q3:过期日期是您的证书而不是应用程序。应用程序将安装并正常运行。使用同一证书到期后,您将无法签署新的更新。除非手动更改,否则它们默认可用 25 年。

在此处查看更多信息:https://developer.android.com/studio/publish/app-signing