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

安卓怎麼關閉列印

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

熱點內容
隨機啟動腳本 發布:2025-07-05 16:10:30 瀏覽:516
微博資料庫設計 發布:2025-07-05 15:30:55 瀏覽:19
linux485 發布:2025-07-05 14:38:28 瀏覽:299
php用的軟體 發布:2025-07-05 14:06:22 瀏覽:751
沒有許可權訪問計算機 發布:2025-07-05 13:29:11 瀏覽:425
javaweb開發教程視頻教程 發布:2025-07-05 13:24:41 瀏覽:687
康師傅控流腳本破解 發布:2025-07-05 13:17:27 瀏覽:234
java的開發流程 發布:2025-07-05 12:45:11 瀏覽:680
怎麼看內存卡配置 發布:2025-07-05 12:29:19 瀏覽:277
訪問學者英文個人簡歷 發布:2025-07-05 12:29:17 瀏覽:828