Sometimes we may want to set different address of the back-end web service for debuggable and release version of our Android app. E.g. predefined static host and port for release version of the application and our local IP address and predefined port for debuggable version of the application. In second case, we can deploy back-end webservice on our local machine for testing purposes. We can customize all of that in build.gradle file. We can use variant.buildType.isDebuggable() instruction to check build type of the app. I described way of Updating Android XML resources before compilation via Gradle in one of my previous posts, so you can check it if you don’t understand replaceBackendAddressInResources(variant, host, port) method. After proper configuration, setting of the back-end url is straightforward. Please check the code between // configuration of the back-end address - begin
and // configuration of the back-end address - end comments.

Now, you can create release and debug version of the app with different addresses of the web service what is very useful during the process of development and deployment of the project. We can use this trick also for setting different parameters depending on our needs.