1.在工程中的AndroidManifest.xml下,Application 有个android:debuggable属性

用法如下:

    <application        android:allowBackup="true"        android:icon="@drawable/ic_launcher"        android:label="@string/app_name"        android:theme="@style/AppTheme"         android:debuggable="false">。。。。。。。
使用这种方式,从Eclipse的LogCat来看,在单独的应用的Log过滤器下(com.android.test(Session Filter)),是没有log信息的,但是在“All messages(no filters)”下还是可以看见log信息的。

2.自己写个Log工具类,通过定义一个开关变量来实现log打印的开关。

如:

import android.util.Log;public class LogHelper {public static booleanisDebug= false;public static void v(String tag, String msg) {if (isDebug) {Log.v(tag, msg);}}public static void d(String tag, String msg) {if (isDebug) {Log.d(tag, msg);}}}


3.Android 有个工具叫 Proguard 代码混淆器

详细文档参见:http://developer.android.com/tools/help/proguard.html#configuring

中文文档参见:http://www.cnblogs.com/over140/archive/2011/04/22/2024528.html

步骤:

1.创建一个Android 工程,默认会在根目录下建立一个proguard.cfg的文件(如果没有可以手动建一个)

2.在project.properties 文件中,添加如下内容: android.proguard = proguard.cfg

3.在proguard.cfg文件中添加以下内容:

-assumenosideeffects class android.util.Log {    public static *** d(...);    public static *** v(...);    public static *** i(...);}

//分别是过滤Log.d() ,Log.v(),Log.i() 的信息。

注意:如果要让代码混淆器可以工作,则必须ant release 或者 Eclipse 导入签名软件。否则,proguard不会在Debug的程序中起作用。



更多相关文章

  1. Android(安卓)Studio的使用总结
  2. 安全卫士笔试 第一天
  3. Okhttp的简单介绍和使用(一)
  4. ffmpeg入门教程之Android使用FFmpeg so(封装格式转换)
  5. Android(安卓)JNI 开发简单介绍
  6. Android中Dialog自带蒙层适配状态栏
  7. [android]android自动化测试十一之代码覆盖率报告EMMA
  8. U3D不同平台载入XML文件的方法——IOS MAC Android
  9. TensorFlow for Android(安卓)PB模型的优化

随机推荐

  1. ImageView的属性android:scaleType
  2. androidx.core.widget.NestedScrollView
  3. android中的menu和子menu小结
  4. 如何手工创建android项目
  5. 如何使用android中的搜索功能
  6. 从android游戏框架看其生命周期!
  7. Android(安卓)webview 调用android浏览器
  8. android sdk 下载地址
  9. Android(安卓)五大布局之(一) 线性布局和相
  10. android中的震动