Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

switching code between debug mode and release mode in java - android

Tags:

java

android

I would like to know if anyone has any idea of how to switch code between debug mode and release mode? For example, in C#, there is #debug to differentiate the debugging code. The code within #debug only executes in debug mode.

Thanks for any help in advance.

like image 632
Charles LAU Avatar asked Apr 17 '13 14:04

Charles LAU


1 Answers

According to this (revision March 2012) :

Build
Added a feature that allows you to run some code only in debug mode. Builds now generate a class calledBuildConfigcontaining aDEBUGconstant that is automatically set according to your build type.
You can check the (BuildConfig.DEBUG) constant in your code to run debug-only functions.

like image 114
Alexis C. Avatar answered Oct 20 '22 14:10

Alexis C.