I am trying to pass environment specific values to Android studio v 2.2.2 (such as server url, keystore location and password) by setting java vm arguments. So far I've tried following options but nothing has worked.
1. Setting the java-vm arguments from studio.vmoptions (as documented here)
I clicked Help -> Edit Custom VM Options...
to create a new vmoptions file which is created at ~/.AndroidStudio2.2/studio64.vmoptions. I have edited the file to add following line.
-DRELEASE_KEY_STORE_PATH=/home/ubuntu/ks/myapp/app-release.keystore
2. With a gradle.properties
file
I have created a gradle.properties file in the same directory where the root build.gradle file exists. The file has following contents.
RELEASE_KEY_STORE_PATH=/home/ubuntu/ks/myapp/app-release.keystore
3. Edited the studio.sh file
I have also tried editing the studio.sh file, added following line hoping these properties will be available to Android Studio.
export RELEASE_KEY_STORE_PATH=/home/ubuntu/ks/myapp/app-release.keystore
My build.gradle file has signingConfig section where this value is used.
signingConfigs {
release {
storeFile file(System.env.RELEASE_KEY_STORE_PATH)
storePassword System.env.RELEASE_KEYS_STORE_PASSWORD
keyAlias System.env.RELEASE_KEY_ALIAS
keyPassword System.env.RELEASE_KEY_PASSWORD
}
}
The build fails when gradle project sync / build runs from Android Studio.
The error is displayed: Neither path nor baseDir may be null or empty string. path='null' basedir='/home/ubuntu/path-to-project'.
This means that script is not able to resolve the file path as it is coming null.
UPDATE If I run the gradle build from command line it perfectly works, build succeeds, all I have to do is just fire some export commands for the desired properties I want to inherit in build.
Following is my dev environment:
- Gradle version used by Android Studio: 2.14.1
- Gradle plugin version: 2.3.1
- Android Studio version: 2.2.2
- Java version: oracle jdk 1.8.0_111
- OS: Ubuntu 16.04 amd64
System.env.RELEASE_KEY_STORE_PATH
or justRELEASE_KEY_STORE_PATH
? It should be the second one since it's not an environment variable. – DeeVSystem.env.RELEASE_KEY_STORE_PATH
in build script. If I use justRELEASE_KEY_STORE_PATH
it works in Android Studio but now the build fails in command line. – Pawan