Configuring manually in Gradle ⚓
You can manually specify the code signing configuration in your Gradle configuration so that your app gets signed during the build process.
- Open your module-level
build.gradle
file. - Add the
signingConfigs
codeblock to your code and define the following entries specific to your project:storeFile
,storePassword
,keyAlias
, andkeyPassword
. - Attach the signing config to a build type.
Example signing configuration:
android {
// Make sure signingConfigs is defined before buildTypes.
signingConfigs {
release {
keyAlias 'MyAndroidKey'
keyPassword '***'
storeFile file("/path/to/my/keystore.jks")
storePassword '***'
}
}
buildTypes {
release {
// Use signing config for build type
signingConfig signingConfigs.release
// ...
}
}
// ...
For more information, check out how to configure Gradle to sign your app.
About environment variables ⚓
You can avoid having the same keystore path locally and on bitrise.io by using configuration values and Environment Variables in the keystore path (storeFile
) and in the keystore password.
If your keystore path is $HOME/keystores/my_keystore.jks
, then your build.gradle
file looks like this:
android {
signingConfigs {
release {
keyAlias 'MyAndroidKey'
keyPassword '***'
storeFile file(System.getenv("HOME") + "/keystores/my_keystore.jks")
storePassword '***'
}
} ...
You can use the System.getenv("ENV_KEY")
file to access Environment Variables in the Gradle config file.
Add the file donwloader step to download the keystore:
- file-downloader@1:
inputs:
- destination: "$HOME/keystores/my_keystore.jks"
- source: "$BITRISEIO_ANDROID_KEYSTORE_URL"
- gradle-runner@1:
inputs:
- gradle_task: assembleRelease
- gradlew_path: "./gradlew"
If you use Environment Variables as keyPassword
and storePassword
in the Code signing tab, your build.gradle
will look like this:
android {
signingConfigs {
release {
keyAlias System.getenv("BITRISEIO_ANDROID_KEYSTORE_ALIAS")
keyPassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD")
storeFile file(System.getenv("HOME") + "/keystores/my_keystore.jks")
storePassword System.getenv("BITRISEIO_ANDROID_KEYSTORE_PASSWORD")
}
}
buildTypes {
release {
// Use signing config for build type
signingConfig signingConfigs.release
// ...
}
}
...
You get these Environment Variables when you upload your keystore to the GENERIC FILE STORAGE field of the Code Signing tab in your Workflow Editor.