Best Way to Include Debug Code?

后端 未结 7 1244
既然无缘
既然无缘 2020-12-24 01:43

I am programming Android applications, and the best way here may or may not be the same as Java in general.

I simply want to be able to set a debug flag that will on

7条回答
  •  被撕碎了的回忆
    2020-12-24 02:11

    This works for me with code if (BuildConfig.DEBUG), using the BuildConfig class. This is a safe and easy code to do. Be careful when using this style of code. Don't use it such that there are 2 different distinct branches of code, between Release and Debug versions. If you do, it might invalidate the app testing for the Release version. For me, I have used it only to skip calling Log messaging.

    More details on this class BuildConfig @ Build System Concepts.

提交回复
热议问题