Skip to main content

Android signing keystore details from Gradle properties


We may want to keep our Android project keystore details out of our source code and Git by passing them in. Aided by a handy function, these can be referenced from Gradle in Groovy or Kotlin.

import org.gradle.api.Project

fun Project.propertyOrEmpty(name: String): String {
    return findProperty(name) as String? ?: ""

android {
  signingConfigs {
    create("upload") {
      storeFile = file("upload.keystore")
      storePassword = propertyOrEmpty("UPLOAD_STORE_PASSWORD")
      keyAlias = "keyname"
      keyPassword = propertyOrEmpty("UPLOAD_KEY_PASSWORD")

I hope the article was useful. If you have any feedback or questions please feel free to reach out.

Thanks for reading!

Like what you read? Please share the article.

Avatar of Andrew Lord


Andrew Lord

A software developer and tech leader from the UK. Writing articles that focus on all aspects of Android and iOS development using Kotlin and Swift.

Want to read more?

Here are some other articles you may enjoy.