Android APK 签名 V1 和 V2 冲突
Android APK signatures V1 and V2 conflict
具有 V1 签名的 APK 已经在 Google 播放并安装在设备爱好者 Android 11 上。
现在我们要支持Android11台设备,但是需要V2签名。
启用 V1 和 V2 的复选框我们得到 APK,但它拒绝安装 INSTALL_FAILED_UPDATE_INCOMPATIBLE。
如何构建所有设备都支持的 APK?
我检查了内置 APK 的签名证书。它们是发布证书。
一些可能有用的日志片段:
2021-05-31 23:20:41.525 23694-27663/? I/Finsky: [6921] VerifyPerSourceInstallationConsentInstallTask.mJ(2): PSIC verification started with installer uid: 2000 package name: null, originating uid: -1
2021-05-31 23:20:41.527 23694-23694/? I/Finsky: [2] VerifyInstallTask.j(3): Verifying id=30, result=1
2021-05-31 23:20:41.528 1129-5146/? D/PackageManager: [VERIFY] verifyPendingInstall(30, ALLOW), uid=10072
2021-05-31 23:20:41.528 1129-1571/? D/PackageManager: [VERIFY] PACKAGE_VERIFIED:
PackageVerificationState{
verifier packages=com.android.vending(10072),
intent=Intent { act=android.intent.action.PACKAGE_NEEDS_VERIFICATION dat=file:///data/app/vmdl129480116.tmp typ=application/vnd.android.package-archive flg=0x10000001 cmp=com.android.vending/com.google.android.finsky.verifier.impl.PackageVerificationReceiver (has extras) }
others=30, false, false, false, false, false
}
2021-05-31 23:20:41.529 1129-1571/? D/PackageManager: [VERIFY] setVerifierResponse {verificationID=30, uid=10072, code=1}
2021-05-31 23:20:41.529 1129-1571/? D/PackageManager: [VERIFY] packageVerificationCompletion: completed id=30
2021-05-31 23:20:41.529 23694-23694/? I/Finsky: [2] VerifyInstallTask.mI(6): Verification complete: id=30, package_name=com.our.app
2021-05-31 23:20:41.550 1129-1571/? W/PackageManager: verifying app can be installed or not
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG WL - false
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG BL - true
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PERM BL - true
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking SIG BL - true
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG WL - false
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG BL - true
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PERM BL - true
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking SIG BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG WL - false
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PERM BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking SIG BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG WL - false
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PERM BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking SIG BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : enabled true
2021-05-31 23:20:41.552 1129-1571/? W/PackageManager: Package com.our.app signatures do not match previously installed version; ignoring!
2021-05-31 23:20:41.571 1129-1571/? D/PackageManager: result of install: -7{216565249}
2021-05-31 23:20:41.572 1143-28449/? E/installd: Couldn't opendir /data/app/vmdl129480116.tmp: No such file or directory
2021-05-31 23:20:41.572 1143-28449/? E/installd: Failed to delete /data/app/vmdl129480116.tmp: No such file or directory
2021-05-31 23:20:41.574 1129-4377/? D/PackageInstallerSession: Ignoring abandon after commit relinquished control
问题似乎与 v1 和 v2 签名无关,而与您用于对应用程序签名的密钥库有关。
错误消息 Package com.our.app signatures do not match previously installed version; ignoring!
表示当前安装在设备上的应用未使用与您尝试安装的相同的密钥进行签名。
您是否参加了 Play 应用签名(您可以在 Play 管理中心的“应用完整性”页面中查看)?如果是这样,您可能安装了由 Google 的应用签名密钥签名的应用版本,并且您正在尝试安装使用上传密钥签名的应用版本(在 Studio 中称为“释放键”)。
如果您卸载该应用并使用 v1+v2 签名的 APK 重新安装它,它应该可以正确安装。
具有 V1 签名的 APK 已经在 Google 播放并安装在设备爱好者 Android 11 上。 现在我们要支持Android11台设备,但是需要V2签名。 启用 V1 和 V2 的复选框我们得到 APK,但它拒绝安装 INSTALL_FAILED_UPDATE_INCOMPATIBLE。
如何构建所有设备都支持的 APK?
我检查了内置 APK 的签名证书。它们是发布证书。
一些可能有用的日志片段:
2021-05-31 23:20:41.525 23694-27663/? I/Finsky: [6921] VerifyPerSourceInstallationConsentInstallTask.mJ(2): PSIC verification started with installer uid: 2000 package name: null, originating uid: -1
2021-05-31 23:20:41.527 23694-23694/? I/Finsky: [2] VerifyInstallTask.j(3): Verifying id=30, result=1
2021-05-31 23:20:41.528 1129-5146/? D/PackageManager: [VERIFY] verifyPendingInstall(30, ALLOW), uid=10072
2021-05-31 23:20:41.528 1129-1571/? D/PackageManager: [VERIFY] PACKAGE_VERIFIED:
PackageVerificationState{
verifier packages=com.android.vending(10072),
intent=Intent { act=android.intent.action.PACKAGE_NEEDS_VERIFICATION dat=file:///data/app/vmdl129480116.tmp typ=application/vnd.android.package-archive flg=0x10000001 cmp=com.android.vending/com.google.android.finsky.verifier.impl.PackageVerificationReceiver (has extras) }
others=30, false, false, false, false, false
}
2021-05-31 23:20:41.529 1129-1571/? D/PackageManager: [VERIFY] setVerifierResponse {verificationID=30, uid=10072, code=1}
2021-05-31 23:20:41.529 1129-1571/? D/PackageManager: [VERIFY] packageVerificationCompletion: completed id=30
2021-05-31 23:20:41.529 23694-23694/? I/Finsky: [2] VerifyInstallTask.mI(6): Verification complete: id=30, package_name=com.our.app
2021-05-31 23:20:41.550 1129-1571/? W/PackageManager: verifying app can be installed or not
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG WL - false
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG BL - true
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PERM BL - true
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking SIG BL - true
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG WL - false
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG BL - true
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PERM BL - true
2021-05-31 23:20:41.551 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking SIG BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG WL - false
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PERM BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking SIG BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG WL - false
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PKG BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking PERM BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : Checking SIG BL - true
2021-05-31 23:20:41.552 1129-1571/? D/ApplicationPolicy: isApplicationInstallationEnabled : enabled true
2021-05-31 23:20:41.552 1129-1571/? W/PackageManager: Package com.our.app signatures do not match previously installed version; ignoring!
2021-05-31 23:20:41.571 1129-1571/? D/PackageManager: result of install: -7{216565249}
2021-05-31 23:20:41.572 1143-28449/? E/installd: Couldn't opendir /data/app/vmdl129480116.tmp: No such file or directory
2021-05-31 23:20:41.572 1143-28449/? E/installd: Failed to delete /data/app/vmdl129480116.tmp: No such file or directory
2021-05-31 23:20:41.574 1129-4377/? D/PackageInstallerSession: Ignoring abandon after commit relinquished control
问题似乎与 v1 和 v2 签名无关,而与您用于对应用程序签名的密钥库有关。
错误消息 Package com.our.app signatures do not match previously installed version; ignoring!
表示当前安装在设备上的应用未使用与您尝试安装的相同的密钥进行签名。
您是否参加了 Play 应用签名(您可以在 Play 管理中心的“应用完整性”页面中查看)?如果是这样,您可能安装了由 Google 的应用签名密钥签名的应用版本,并且您正在尝试安装使用上传密钥签名的应用版本(在 Studio 中称为“释放键”)。
如果您卸载该应用并使用 v1+v2 签名的 APK 重新安装它,它应该可以正确安装。