Nitt Nitt - 10 days ago 6
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

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 ){
    }