Nitt Nitt - 1 year ago 120
Android Question

how to run block of code only in release mode in android

I have two builds variant one is in debugging and other is release. I have to run some block of code in release mode.
For example, I have to use Firebase only in the release build,Is there any way to do that?

Answer Source

For Check the release mode use

 if( BuildConfig.BUILD_TYPE.equalsIgnoreCase("release")) {


debug mode check

 if( BuildConfig.BUILD_TYPE.equalsIgnoreCase("debug")) {


or you can use this code

  if( BuildConfig.DEBUG ){
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download