Current location - Quotes Website - Personality signature - V2 signature of apksigner in Android development
V2 signature of apksigner in Android development
In Android 7.0 nougat, a new signature method of APK signature scheme v2 was introduced, and Meituan also launched the corresponding Android channel package generation tool Walle.

After 360 reinforcement, it is necessary to sign a new contract. With the help of Qihoo apk signer, a signature tool provided by 360, v 1 signature was used before 7.0. At this time, the channel number cannot be successfully written into apk by typing the channel packet through walle. At this time, you must use the apksigner tool provided by Android SDK to sign the packaged apk v2.

The official Android documentation has explained the usage of apksigner in detail. Let's talk about practical steps:

Zip alignment, because the essence of apk package is a zip compressed document, through the optimization of boundary alignment, the uncompressed data in the package can be arranged in an orderly manner, thus reducing the memory consumption when the application is running and improving the execution efficiency by exchanging space for time (the size of APK package after Zip alignment increases by about 100KB).

Open cmd, switch the directory to the build-tools directory of SDK (for example, E:\SDK\build-tools\25.0.2\), and execute:

Zipalign command options are few:

-f: the output file overwrites the source file.

-v: detailed output log

-p: outfile.zip should use the same page alignment for all shared object files in infile.zip

-c: Check whether the current APK has performed Align optimization.

In addition, the upper number 4 indicates alignment according to a 4-byte (32-bit) boundary.

This tool is located in the build-tools directory of the SDK directory. It must be noted that v2 signature mode was introduced after Android7.0, so only version >: 25 SDK\build-tools\ can find apksigner.jar

Open cmd, cut the directory to SDK \ build-tools \ versionnumber \ lib (for example, E:\SDK\build-tools\25.0.2\lib), and execute:

Example:

Apksigner also supports some other options. Click here for details. Including specifying min-sdk version, max-sdk version, outputting detailed information, checking whether apk has been signed, and so on.

For example, check whether apk is signed:

Zipalign+apksigner, complete v2 signature of apk package in two steps. The above tools are located in the build-tools of the AndroidSDK directory.