Pedro Varela Pedro Varela - 1 year ago 99
Android Question

Different files and gradle android studio

I have a project where I need to generate two versions.
One pointing to development servers and the other to production servers. The previous developers created a configuration file .properties there they have the endpoints set up.
My questions is. How can I modify or generate the two versions with Android Studio. I know about the flavors and build types, but is there a way to keep lets say two .properties files and the compiler use them in each case.

Best regards


Answer Source

You want to use Gradle flavors. In a nutshell, it allows you to include different resources in different build-time variations (flavors).

In your build.gradle,

android {
  productFlavors {
    flavor1 {
    flavor2 {

This will create two different APKS, one for each flavor. Now, in your src tree,


Now for example if your .properties file was stored as an asset, you'd have src/flavor1/assets/ and src/flavor2/assets/

You can also include different source files, and Android manifests. The directory structure under the flavor folder is the same as you'd find in main and can contain all of the same resources.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download