Search code examples
androidrelease-modedebug-mode

How can I know if my android app was built in release or debug mode?


In my app I use Google Analytics and Admob as you know (or not) I can use both of them in a mode that doesn't influences the data on the server (debug mode).

I tired of changing each time I release my app this things and I can also mistake and release it with debug mode and then I won't get data...

How can I know programmatically if I run in debug\release mode?

In C# I can check this using:

#If DEBUG then

How can I do this in Android?


Solution

  • You can try by checking the flag

    BuildConfig.DEBUG

    And this is how I use normally.

    if (BuildConfig.DEBUG) {
      Log.e(Constants.TAG, "onCreate called");
    }