Release-Debug Builds for Android Application

前端 未结 5 731
一生所求
一生所求 2021-01-04 21:22

In C++ I would normally setup 2 builds - debug and release with each having DEBUG and RELEASE predefined respectively. I would then use these defin

5条回答
  •  一生所求
    2021-01-04 22:12

    I normally create a separate log class where i set a static DEBUG variable. Now all i need to go before getting a production build is to set that DEBUG variable to false.

    public class Log {
         public final static String LOGTAG = "APP NAME";
    
          public static final boolean DEBUG = true;
    
          public static void v(String msg) {
            android.util.Log.v(LOGTAG, msg);
          }
    
          public static void e(String msg) {
            android.util.Log.e(LOGTAG, msg);
          }
    
          public static void d(String msg) {
              android.util.Log.d(LOGTAG, msg);
          }
    }
    

    For logging -

    if(Log.DEBUG) Log.v("In some function x. Doing y.");
    

提交回复
热议问题