ApkSign
ApkSign provides apK with fast signature, hands free and automated processes. Solve the application scenarios that require quick signature, such as “Tencent Legu” reinforcement without signature
How to use Gradle plug-ins
To configure the build. Gradle
Add the ApkSign plugin dependency to the build.gradle file located at the root of your project as follows:
buildscript {
dependencies {
classpath 'com. Zf. Plugins: ApkSign: 1.0.2'}}Copy the code
Apply the plugin to the build.gradle file of the current App
apply plugin: 'apksign'
Copy the code
Configure plug-ins (simplest configuration)
apkSignConfig {
items {
ddebug {
// APK path to be signed
inputApkFilePath file("build/outputs/apk/tap_unsign.apk").absolutePath
}
/ /... You can add more options}}Copy the code
Plug-in configuration
apkSignConfig {
/ / unified configuration priority is lower than the custom configuration -- -- -- -- -- -- -- -- -- -- -- -- start -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
// Optional, default is false. After the signature is complete, determine whether to enter the directory where the signed APK resides. Only Windows is supported
isOpenOutputDir true
// Optional, customize signature JAR package location
signJarFilePath new File("E: \ \ Android \ \ SDK \ \ build - tools \ \ 28.0.3 \ \ lib \ \ apksigner jar").absolutePath
// Optional, customize the apK package alignment command position
zipalignExeFilePath new File("E: \ \ Android \ \ SDK \ \ build - tools \ \ 28.0.3 \ \ zipalign exe").absolutePath
// Optional, custom signature JAR package, apk alignment command used version,
buildToolsVersion '28.0.3'
// Optional, customize the signature file
signingInfo {
storeFilePath "sign.jks"
storePassword "XXXXX"
keyAlias "XXXXXX"
keyPassword "XXXXXX"
}
// Optional, use the signature configuration named 'debug' in android project
signingName 'debug'
// Unified configuration -------------end----------------------
items {
release {
/ / release the custom configuration priority unified configuration -- -- -- -- -- -- -- -- -- -- -- -- start -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
// Optional. The default value is the one in unified configuration. After the signature is complete, determine whether to enter the directory where the signed APK resides. Only Windows is supported
isOpenOutputDir true
// Optional, custom signature JAR package, apk alignment command used version,
buildToolsVersion '28.0.3'
// Optional, customize signature JAR package location
signJarFilePath new File("E: \ \ Android \ \ SDK \ \ build - tools \ \ 28.0.3 \ \ lib \ \ apksigner jar").absolutePath
// Optional, customize the apK package alignment command position
zipalignExeFilePath new File("E: \ \ Android \ \ SDK \ \ build - tools \ \ 28.0.3 \ \ zipalign exe").absolutePath
// Optional, customize the signature file
signingInfo {
storeFilePath "sign.jks"
storePassword "XXXXX"
keyAlias "XXXXXX"
keyPassword "XXXXXX"
}
// Optional, use the signature configuration named 'debug' in android project
signingName 'debug'
/ / release the custom configuration priority unified configuration -- -- -- -- -- -- -- -- -- -- -- -- end -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
// Mandatory. APK path to be signed
inputApkFilePath file("build/outputs/apk/tap_unsign.apk").absolutePath
// Optional: Specify the output directory of the signature APk file. The default directory is the directory where the input APk is located
outputApkDirPath file("build/outputs/apk").absolutePath
}
/ /... You can add more options}}Copy the code
Description of the configuration items:
-
When both signJarFilePath and buildToolsVersion are configured, the optimization level is signJarFilePath> buildToolsVersion. When neither configuration item is configured, the android project’s buildToolsVersion is used by default.
-
SignJarFilePath,buildToolsVersion when configured, optimization level is signJarFilePath > buildToolsVersion; When neither configuration item is configured, the android project’s buildToolsVersion is used by default.
-
SigningInfo,signingName When both are configured, the optimization level is signingInfo > signingName. When neither configuration item is configured, the default Debug signature in the Android project is used by default.
-
SigningName =’release’ The name of the signature configuration,
android { signingConfigs { release { storeFile signingInfo.storeFile storePassword signingInfo.storePassword keyAlias signingInfo.keyAlias keyPassword signingInfo.keyPassword v1SigningEnabled true v2SigningEnabled true}}}Copy the code
Generate apK signature package:
/gradlew apkSign${your signature configuration name (home letter size)}
To generate a signature package, run the following command:
./gradlew apkSignRelease
Source: github.com/903600017/A…