Skip to content

zhangwanyue/SignApkWithGradle

Repository files navigation

configure gradle to sign apk

ref link:

procedure

  1. generate keystore

using keytool to generate keystore:

keytool -genkey -v -keystore my-release-key.keystore
-keyalg RSA -keysize 2048 -validity 10000 -alias my-alias
$ which keytool 
/usr/lib/jvm/jdk1.8.0_161/bin/keytool
  1. configure gradle for signing and keep the key secure
  • create a keystore.properties
storeFile=xxx
storePassword=xxx
keyAlias=xxx
keyPassword=xxx
  • configure gradle
// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("app/keystore.properties")
// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()
// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    ...
    signingConfigs{
        release{
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
        }
    }
    buildTypes {
        release {
            ...
            signingConfig signingConfigs.release
        }
    }
}

About

使用gradle对apk进行自动签名

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages