當前位置:首頁 » 安卓系統 » 安卓怎麼關閉列印

安卓怎麼關閉列印

發布時間: 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 不要優化;將會關閉優化,導致日誌語句不會被優化掉。所以不能有這個配置

熱點內容
mysql自動備份腳本 發布:2024-05-22 05:55:16 瀏覽:930
c語言單片機埠 發布:2024-05-22 05:55:05 瀏覽:162
c目錄文件夾 發布:2024-05-22 05:36:45 瀏覽:107
編程貓微課 發布:2024-05-22 05:36:37 瀏覽:655
兒童編程的書 發布:2024-05-22 05:35:49 瀏覽:580
加密技術挑戰 發布:2024-05-22 05:09:01 瀏覽:985
懷舊服玩小號去什麼伺服器 發布:2024-05-22 04:52:22 瀏覽:559
網頁無法上傳照片 發布:2024-05-22 04:34:04 瀏覽:194
奇特解壓圖解大全 發布:2024-05-22 04:04:38 瀏覽:649
學php8 發布:2024-05-22 03:56:56 瀏覽:740