Android: Use the build-tools in the sdk to sign the package

Sometimes we need to sign different apk packages with the specified signature file, the signature method is as follows.

Signature tool:

Use the apksigner.jar in the sdk that comes with AndroidStudio installation to sign. The file directory is generally in \Android\Sdk\build-tools\29.0.2\lib. Note that only 24.0.3 and later versions will have this jar tool. Here, v1 and v2 signatures will be signed by default. Android9.0 and above will sign v1, v2 and v3 signatures by default.

Signature directive:

Sign the apk: apksigner sign --ks keystoreFileAbsolutePath apkAbsolutePath

like:

./apksigner sign --ks /Users/lucas/AndroidStudioProjects/lucas/yanyou.jks  /Users/lucas/Desktop/OPPOSignVerifyPackage/OppoSignVerify.apk

If the keystore has multiple aliases, you need to specify the alias to sign the apk: apksigner sign --ks keystoreFileAbsolutePath --ks-key-alias aliasName apkAbsolutePath

Verify that the signature is successful:

 

Documentation: https://developer.android.google.cn/studio/command-line/apksigner#options-sign

Guess you like

Origin blog.csdn.net/LucasXu01/article/details/126963261