0

I am currently on an Android project where I have to switch the project on two environments(Prod and dev).

In the current scenario I am hardcoding a base url for prod environment, build the project and generate apk. When it comes to dev also hardcoding the corresponding url for dev environment. This becomes difficult as each time we need to switch the environment, we need to make code changes(changing the url) and rebuild the entire code. I found out a similar suggestion in this link clickhere

But I am not clear on how to achieve this. Please help with your suggestions.

Subin Thankachan
  • 101
  • 1
  • 1
  • 7

1 Answers1

1

The easiest way is using BuildConfig.DEBUG. This will return true if you're running a debug version.

if (BuildConfig.DEBUG) {
  // debug version
 } else {
  // release version
}
rxabin
  • 106
  • 1
  • 5