如何使用"APK签名方案v3"对我的应用进行签名? [英] How can I sign my app with "APK Signature Scheme v3"?

查看:74
本文介绍了如何使用"APK签名方案v3"对我的应用进行签名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在文档中,有关于签名v3的说明: https://source.android.com/security/apksigning/v3

Here in the docs, there is the explanation about signature v3 : https://source.android.com/security/apksigning/v3

但是当我尝试使用Build>生成已签名的apk/bundle在android studio中对我的应用进行签名时,我可以仅选中v1(jar签名)和v2(完整apk签名)的复选框,而v3签名则没有任何选择.

But when I try to sign my app in android studio using Build>Generate signed apk/bundle, I can just check checkboxes for v1(jar signature) and v2(full apk signature) and there is no option for v3 signature.

如何使用签名方案v3对我的应用程序签名?

How can I sign my App using signature scheme v3?

谢谢.

推荐答案

正如@Pierre所说,Android Studio不支持创建经过v3方案验证的释放apk.

As @Pierre said, the Android studio is not supporting to create v3 scheme verified releask apk.

为此,我们需要使用命令行手动创建签名的版本.

To do that we need to manually create the signed build using Command line.

请找到创建v3方案签名构建的步骤,

Please find the steps to create v3 scheme signed build,

  1. 选择build-tools \ 29.0.2或更高版本.

  1. Select build-tools\29.0.2 or later version.

注意:您可以在SDK位置内找到build-tools文件夹.

Note: You can find the build-tools folder inside the SDK location.

\ Users \ AppData \ Local \ Android \ Sdk \ build-tools \ 29.0.2

Zipalign-对齐未签名的APK

Zipalign - Align the unsigned APK

zipalign -v -p 4 app-production-debug.apk my-app-unsigned-aligned.apk

zipalign -v -p 4 app-production-debug.apk my-app-unsigned-aligned.apk

注意:

app-production-debug.apk-a.通过Build-> Build Bundles(s)/APK(s)-> Build APK(s)

app-production-debug.apk - a. Apk file you have created from Android studio by Build-> Build Bundles(s)/APK(s)-> Build APK(s)

my-app-unsigned-aligned.apk-文件将在同一目录中创建(您也可以定义路径).

my-app-unsigned-aligned.apk - The file will be created in the same directory(You can define your path as well).

Apksigner-用您的私钥对APK进行签名

Apksigner - Sign your APK with your private key

apksigner标志--ks release-keystore.jks --out my-app-release.apkmy-app-unsigned-aligned.apk

apksigner sign --ks release-keystore.jks --out my-app-release.apk my-app-unsigned-aligned.apk

注意:一种.release-keystore.jks-我们在build.gradle文件

Note: a. release-keystore.jks - Keystore file we have configured in the build.gradle file

   android {
                signingConfigs {
                        production {
                            storeFile file('release-keystore.jks')
                            storePassword 'XXXX'
                            keyAlias = 'AAAAA'
                            keyPassword 'XXXX'
                        }
                }
            buildTypes {
                        release {
                            ...............
                            signingConfig signingConfigs.production 

                        }
            }
        }

b.my-app-release.apk-签名发布版本将在同一目录中生成(您也可以定义路径).

b. my-app-release.apk - Signed release build will be generated in the same directory(You can define your path as well).

  1. 验证:

apksigner验证--verbose my-app-release.apk

apksigner verify --verbose my-app-release.apk

  1. 您可以在发行版APK中看到经过验证的方案.

  1. You can see the schemes that verified in the release apk.

验证

使用v1方案(JAR签名)验证:是

Verified using v1 scheme (JAR signing): true

使用v2方案(APK签名方案v2)验证:是

Verified using v2 scheme (APK Signature Scheme v2): true

使用v3方案(APK签名方案v3)验证:是

Verified using v3 scheme (APK Signature Scheme v3): true

这篇关于如何使用"APK签名方案v3"对我的应用进行签名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆