I want to be able to get system property from the application as:
String isTesting = System.getProperty("IS_TESTING");
I have tried to pass the argument using -D flag in gradle, like ./gradlew assemble -DIS_TESTING. Or doing so:
task setCustomProp << {
System.setProperty("IS_TESTING", "true")
}
preBuild.dependsOn setCustomProp
Even tried to change the gradle.properties adding this line:
org.gradle.jvmargs=-DIS_TESTING=true
But, none of those attempts results on getting the value on the application code. I'm simply trying to get like:
@Override
public void onCreate() {
super.onCreate();
String isTesting = System.getProperty("IS_TESTING");
}
Why don't you just add:
buildConfigField "boolean", "IS_TESTING", "true"
to build.gradle.
and then in your:
@Override
public void onCreate() {
super.onCreate();
boolean isTesting = BuildConfig.IS_TESTING
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With