android怎么在release版下不输出日志
1个回答
2016-09-14 · 专业始于专注 卓识源于远见
华清远见
华清远见于04年成立,13年始终专注于IT人才培养,目前业务涉及嵌入式、HTML5、JAVA、大数据、Android、UI、VR、物联网等学科,“做良心教育,做专业教育,做受人尊敬的职业教育
向TA提问
关注
展开全部
主要有两种方法:
方法一:如果有做代码混淆,在配置文件中加入下面语句
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
}
方法二:对于没做代码混淆的,可以按照下面方法:
在manifest文件中加入android:debuggable="@bool/build_log"
android:name="MyApplication"
android:icon="@drawable/gift"
android:label="@string/app_name" android:debuggable="@bool/build_log">
定义一个日志类
public class Lol {
public static final boolean ENABLE_LOG = true & MyApplication.sDebug;
private static final boolean DEBUG = true & ENABLE_LOG;
private static final boolean VERBOSE = true & ENABLE_LOG;
private static final boolean TEMP = true & ENABLE_LOG;
private static final boolean WARNING = true & ENABLE_LOG;
private static final boolean INFO = true & ENABLE_LOG;
private static final boolean ERROR = true & ENABLE_LOG;
public static void obvious(String tag, String msg) {
if (DEBUG) {
msg = "*********************************\n" + msg
+ "\n*********************************";
Log.d(tag, msg);
}
}
public static void d(String tag, String msg) {
if (DEBUG)
Log.d(tag, msg);
}
public static void d(boolean bool, String tag, String msg) {
if (TEMP&bool)
Log.d(tag, msg);
}
public static void i(String tag, String msg) {
if (INFO)
Log.i(tag, msg);
}
public static void e(String tag, String msg) {
if (ERROR)
Log.e(tag, msg);
}
public static void e(boolean bool, String tag, String msg) {
if (TEMP&bool)
Log.e(tag, msg);
}
public static void v(String tag, String msg) {
if (VERBOSE)
Log.v(tag, msg);
}
public static void w(String tag, String msg) {
if (WARNING)
Log.w(tag, msg);
}
public static String getStackTraceString(Exception e) {
return Log.getStackTraceString(e);
}
public static void w(String tag, String msg, Exception e) {
if (WARNING)
Log.w(tag, msg,e);
}
}
方法一:如果有做代码混淆,在配置文件中加入下面语句
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
}
方法二:对于没做代码混淆的,可以按照下面方法:
在manifest文件中加入android:debuggable="@bool/build_log"
android:name="MyApplication"
android:icon="@drawable/gift"
android:label="@string/app_name" android:debuggable="@bool/build_log">
定义一个日志类
public class Lol {
public static final boolean ENABLE_LOG = true & MyApplication.sDebug;
private static final boolean DEBUG = true & ENABLE_LOG;
private static final boolean VERBOSE = true & ENABLE_LOG;
private static final boolean TEMP = true & ENABLE_LOG;
private static final boolean WARNING = true & ENABLE_LOG;
private static final boolean INFO = true & ENABLE_LOG;
private static final boolean ERROR = true & ENABLE_LOG;
public static void obvious(String tag, String msg) {
if (DEBUG) {
msg = "*********************************\n" + msg
+ "\n*********************************";
Log.d(tag, msg);
}
}
public static void d(String tag, String msg) {
if (DEBUG)
Log.d(tag, msg);
}
public static void d(boolean bool, String tag, String msg) {
if (TEMP&bool)
Log.d(tag, msg);
}
public static void i(String tag, String msg) {
if (INFO)
Log.i(tag, msg);
}
public static void e(String tag, String msg) {
if (ERROR)
Log.e(tag, msg);
}
public static void e(boolean bool, String tag, String msg) {
if (TEMP&bool)
Log.e(tag, msg);
}
public static void v(String tag, String msg) {
if (VERBOSE)
Log.v(tag, msg);
}
public static void w(String tag, String msg) {
if (WARNING)
Log.w(tag, msg);
}
public static String getStackTraceString(Exception e) {
return Log.getStackTraceString(e);
}
public static void w(String tag, String msg, Exception e) {
if (WARNING)
Log.w(tag, msg,e);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |