I am using Android Studio to build my project on an Ubuntu 14.04 system.
I wrote the following in my build.gradle files to avoid hardcoding storeFile, storePassword,
Create a gradle.properties file in your source folder (alongside build.gradle) to apply only to the current project or in ~/.gradle/gradle.properties to apply system-wide with the contents:
keystore=/home/myname/keystore/mykey
keystore_password=mypass
key_alias=mykey
key_password=keypass
Now update your build.gradle file with:
debug {
storeFile file("${keystore}")
storePassword "${keystore_password}"
keyAlias "${key_alias}"
keyPassword "${key_password}"
}
Optionally, you could pass the parameters from command-line with the -P option. For example, ./gradlew assemble -Pkey_password=keypass.
I also like having my keystore information on my environment variables, rather than having it inside the project. Your code seems fine, but I was having the same issue with the file path. I solved it by converting that value to string before passing it to file():
signingConfigs {
debug {
storeFile file(String.valueOf(System.getenv("KEYSTORE")))
storePassword System.getenv("KEYSTORE_PASSWORD")
keyAlias System.getenv("KEY_ALIAS")
keyPassword System.getenv("KEY_PASSWORD")
}
Hope this helps.