Android studio signature packaging APK tutorial


When APK is released to the application market, it needs to upload the release version APK with key signature. Here are two methods of packaging signature APK.

1. Generate signature file

Method for Android studio to generate signature file

2. Generate APK file
  • Tool signature packaging
    1) Select generate signed bundle / APK… In the build menu;

    Android studio signature packaging APK tutorial

    2) Select APK and click next;
    Android App bundle: it is used for applications published through Google play. It needs to be upgraded to as 3.2 or above to support app bundle format;
    Apk: used to create a signed APK that can be deployed to the device;

    Android studio signature packaging APK tutorial

    3) Click choose existing Select the location of the keystore file, fill in the correct keystore password and key password, and click next;
    Key store path: key store file path;
    Key store password: key store password;

    Key alias: nickname of key;
    Key password: key password;

    Android studio signature packaging APK tutorial

    4) Select the APK output location and APK signature version type, check V1 (jar signature) and V2 (full APK signature), and click Finish to wait for the completion of packaging and signature;

Debug: it is a beta version, including debugging and log information, without optimization and encryption, which is suitable for program debugging;
Release: it is a release version, which is released to the public for use by users, and is optimized and encrypted;

Android studio signature packaging APK tutorial

Differences between V1 and V2:

  • V1 (jar signature): only verify the contents of the unzipped file, so that many modifications can be made after APK signing, and the file can be moved or even recompressed;

  • V2 (full APK signature): verify all bytes of the compressed file instead of a single zip entry. Cannot be changed after signing. So now in the compilation process, we combine compression, adjustment and signing into one step.
    Summary of V1 and V2 usage:

  • When packaging signatures, only checking V1 signature will not affect anything, but more secure verification methods will not be used in 7.0 and above;

  • Only check V2 signature. If it is installed below 7.0, it will directly show that it is not installed, and if it is 7.0 or above, it will be verified by V2;

  • Check V1 and V2 at the same time, then all models are OK.
    5) After packaging, we will see the APK package after packaging and signing under the output path we set/ release/app-release. Apk and output json。

  • Gradle signature package

1) Package signature configuration:
Please move the vehicle for detailed configuration method——Android studio packaging signature configuration method

2) Execute package command:
Method 1:
Open the gradle on the right, find project – > tasks – > build – > assembly, double-click to run, and start compiling, packaging and signing;
Assemble and generate APK packages of debug and release modes at the same time;
Assemblydebug, generate APK package of debug mode;
Assemblyrelease: generate APK package of release mode

Android studio signature packaging APK tutorial

Method 2:
Execute the packaging command in the terminal window;

Command of release package:
gradlew assembleRelease
Debug package command:
gradlew assembleDebug
Commands packaged by release and debug:
gradlew assemble
3) After packaging, check the debug or release installation package in APP / build / outputs / APK / under the project.

Android studio signature packaging APK tutorial