Signing Key
Create Signing Keystore
Using keygen
cd YOUR_ANDROID_PROJECT_FOLDER_LOCATION
keytool -genkey -v -keystore [APPNAME].keystore -alias [APP_ALIAS] -keyalg RSA -keysize 2048 -validity 10000
change [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
*.properties
file (secret.properties
orkeystore.properties
) containing the keystore credentials (inandroid
folder if you are using ionic or flutter):
storePassword=YOUR_KEYSTORE_PASSWORD
keyAlias=YOUR_KEY_ALIAS
keyPassword=YOUR_KEY_PASSWORD
storeFile=YOUR_KEYSTORE_FILE_LOCATION
Variable 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.gradle
for 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
signingConfigs
to 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)