Using Different Sources for Testing and Release Android Studio


I am writing tests to code that make calls to a RESTful web service. I need to use different variables for testing, staging and production. For an example staging release url can be ‘’ whereas when I test the staging flavor it should be ‘localhost/27015’. Same goes for the production flavor. When it is the release it should be ‘’. How do I achieve these flavor, buildType combinations?


You can use the BuildType and the flavor to achieve it.

If you want different url for the different combination you can use a values inside your resources.

Using flavor1, flavor2 you have 4 Build Variants.
You can set the url inside the a resource, for example in the strings.xml file.
Then you can set different files in these folder to achieve what you want.


You can set all the other values, for example the applicationId , in the build.gradle file.

Answered By – Gabriele Mariotti

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published