Changing properties file based on buildType

I am trying to change a properties file entry based on the buildVariant. For instance, I want to set inProduction = true if I am generating a signed APK and inProduction = false otherwise. I can’t seem to figure out how to do this.

I am using productFlavors and I know the task I need to run is:

productFlavors.all { flavor ->


file: “src/$”) {

entry (key: “inProduction”, value:depends)

} }

How would I accomplish this in Android Studio? Sorry for the trivial question, very new to Android development.

I am not sure what you mean by “accomplish this in Android Studio”. Android Studio uses your Gradle build. Can you elaborate on what you mean?

Absolutely. I wanted to mention I am using Android Studio because I wasn’t sure if it was a different version of Gradle.

The issue is the same, I need to update my build.gradle to change the above mentioned properties file depending on which build variant I use.

For instance, in AS I select the demoDebug variant (demo is one of my product flavors) and I want the inProduction property in the file to be set to false. When I choose the demoRelease variant, I want that property set to true when it builds.

Does this make sense? I really just don’t want to have to remember to change that property before I Generate a Signed APK.