[置顶] Android开发中正确删除Log的姿势(proguard.config=proguard.cfg)
2015-06-26 16:59
477 查看
方法一:自定义LogUtils工具类,定义Log打印开关,如:
if(Buildconfig.DEBUG)
{
Log.d(TAG,"The Log is Printed.);
}
方法二:
最好的方法是,使用Android系统的the ProGuard tool.
什么是he ProGuard tool?Android 的Documentation这样写的:
在Android工程的根目录下,需要在project.properties先配置一下,Android开发环境默认是没有开启这个功能的:
打开project.properties,写下:
proguard.config=proguard.cfg
这样ProGuard tool就开启了。
然后,在proguard.cfg文件中,增加下面的配置信息:
-assumenosideeffects class android.util.Log {
public static *** d(...);
}
这段配置信息的意思是,移除所有的d( )方法,也就是debug log日志的打印全部会移除。
这样,打包文件的时候所有的Debug信息都将会被移除。
ok ,that's right.
we got it!
if(Buildconfig.DEBUG)
{
Log.d(TAG,"The Log is Printed.);
}
方法二:
最好的方法是,使用Android系统的the ProGuard tool.
什么是he ProGuard tool?Android 的Documentation这样写的:
在Android工程的根目录下,需要在project.properties先配置一下,Android开发环境默认是没有开启这个功能的:
打开project.properties,写下:
proguard.config=proguard.cfg
这样ProGuard tool就开启了。
然后,在proguard.cfg文件中,增加下面的配置信息:
-assumenosideeffects class android.util.Log {
public static *** d(...);
}
这段配置信息的意思是,移除所有的d( )方法,也就是debug log日志的打印全部会移除。
这样,打包文件的时候所有的Debug信息都将会被移除。
ok ,that's right.
we got it!
相关文章推荐
- Android Animation
- android MD5校验码的生成与算法实现
- Android 存储相关的名词解释
- 解决Android中Handler警告、SimpleDateFormat警告、"String".toUpperCase()警告
- 解决Android中Handler警告、SimpleDateFormat警告、"String".toUpperCase()警告
- 解决Android中Handler警告、SimpleDateFormat警告、"String".toUpperCase()警告
- 解决Android中Handler警告、SimpleDateFormat警告、"String".toUpperCase()警告
- 解决Android中Handler警告、SimpleDateFormat警告、"String".toUpperCase()警告
- android ndk
- Android Matrix理论与应用详解
- Chrome on Android的开发调试技术
- Android 触摸事件传递机制
- 使用自定义的BaseAdapter实现 onitemclickListener
- android:focusable和android:focusableInTouchMode的区别
- Android 注解和反射原理和实现学习(下)
- Android 环境常见问题
- Android 屏幕适配方案
- 高级控件AdapterView(二):通过Observer实现数据、视图同步刷新
- 如何解决Android SDK中离线文档打开慢的问题
- android倒计时(整理)