Signing Key
Create Signing Keystore
Using keygen
cd YOUR_ANDROID_PROJECT_FOLDER_LOCATIONkeytool -genkey -v -keystore [APPNAME].keystore -alias [APP_ALIAS] -keyalg RSA -keysize 2048 -validity 10000change [APPNAME] and [APP_ALIAS] according to your needs
Using Android Studio (recommended)
- Open your android project
- Go to
Build > Generate Signed Bundle or APK. - Choose either App Bundle or APK, click next.
- When asked for key store path, click
Create new...button. - Follow along the instructions.
Manage and using the Signing Key
- Create
*.propertiesfile (secret.propertiesorkeystore.properties) containing the keystore credentials (inandroidfolder if you are using ionic or flutter):
storePassword=YOUR_KEYSTORE_PASSWORD
keyAlias=YOUR_KEY_ALIAS
keyPassword=YOUR_KEY_PASSWORD
storeFile=YOUR_KEYSTORE_FILE_LOCATIONVariable name (
keystorePassword,keyAlias,keyPassword) doesn’t have to be the same as above, this is just example. Don’t forget to exclude this file using.gitignore
- Open the module’s
build.gradle: located inapp/build.gradle(orandroid/app/build.gradlefor ionic or flutter), then load our previously created properties
// Initialize a new Properties() object called keystoreProperties.
Properties keystoreProperties = new Properties()
// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")
// check if keystore properties file exist
if(keystorePropertiesFile.exists()) {
// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}- Add
signingConfigsto refer the signing information stored inkeystoreProperties
android {
signingConfigs {
flavorName {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
}-
Open Build Variants (usually in the left side of the Android studio window) and ensure the selected flavor is correct.
-
Select
Build > Build bundle(s) / APK(s)
References
Last updated on