How to run code block only in release mode in android

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

+4
source share
2 answers

To 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 ){
    }
+7
source

use BuildConfig.DEBUGfor checking in debug mode

0
source

Source: https://habr.com/ru/post/1662009/


All Articles