当前位置:首页 » 安卓系统 » 安卓怎么关闭打印

安卓怎么关闭打印

发布时间: 2023-10-05 19:13:17

‘壹’ android 怎样禁止禁止打印日志

2)配置proguard-------修改proguard配置文件,
如:我的配置文件是:proguard-project.txt
配置为:
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

-dontwarn android.support.**

-keepclassmembers class **.R$* {
public static <fields>;
}
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String,int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}

3)导出关闭日志的apk
proguard,在导出apk的时候才会优化代码,生成优化后的apk。(完成代码混淆也是在导出apk,proguard将代码混淆后生成apk)
通过如上两个步骤,配置project.properties文件和proguard.properties文件;那么项目就配置好了。可以直接导出签名apk,该apk不会输出日志,我们用LogCat是看不到该apk的日志。

assumenosideeffects

assumenosideeffects,proguard 配置文件里的参数。assume no side effects;假定无效;该属性也就是标识无效代码。我们就是通过这个参数来让proguard删除日志代码。
assumenosideeffects的官方解释:
In the optimization step, ProGuard will then remove calls to such methods, if it can determine that the return values aren't used.ProGuard will analyze your program code to find such methods automatically.It will not analyze library code, for which this option can therefore be useful.
In general, making assumptions can be dangerous; you can easily break the processed code. Only use this option if you know what you're doing!

如下:
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
使用这个配置时,一定要注意-dontoptimize,配置。
don‘t optimize 不要优化;将会关闭优化,导致日志语句不会被优化掉。所以不能有这个配置

热点内容
ac68u外网访问 发布:2025-09-17 05:33:12 浏览:903
真我手机如何修改登录密码 发布:2025-09-17 05:20:26 浏览:315
电脑配置怎么说 发布:2025-09-17 04:37:45 浏览:1003
三质数编程 发布:2025-09-17 04:04:41 浏览:562
ftp服务器密码如何修改 发布:2025-09-17 03:48:07 浏览:305
python爬虫豆瓣 发布:2025-09-17 03:41:59 浏览:212
我的世界国际版加入服务器电脑版 发布:2025-09-17 03:41:14 浏览:943
附件上传相片 发布:2025-09-17 03:39:53 浏览:445
微信账号密码组合是什么 发布:2025-09-17 03:30:05 浏览:402
windows如何查看ftp安装环境 发布:2025-09-17 03:30:02 浏览:920