Issue
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 'myapp.staging.com' 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 'myapp.production.com'. How do I achieve these flavor, buildType combinations?
Solution
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.
src/flavor1/
src/flavor1Debug/
src/flavor1Release/
src/flavor2/
src/flavor2Debug/
src/flavor2Release/
You can set all the other values, for example the applicationId
, in the build.gradle
file.
Answered By - Gabriele Mariotti
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.