# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
#
# Starting with version 2.2 of the Android plugin for Gradle, these files are no longer used. Newer
# versions are distributed with the plugin and unpacked at build time. Files in this directory are
# no longer maintained.
# mayq:以下中文註釋都是我加的;
# 混淆後的名字不要同時使用大小寫字母,如果你得到了一個jar,裏面包含a和A,然後當你在windows這種大小寫不敏感的系統上解壓的時候,a和A就會覆蓋;
-dontusemixedcaseclassnames
# 一般情況下library裏的非public類不會被外部引用,跳過他們能加速混淆過程;
# 但是如果library裏有個非public的類C被外部繼承了,而這個C在外部代碼裏被改寫後,就找不到引用了;
-dontskipnonpubliclibraryclasses
# 輸出混淆過程中的詳細信息;
-verbose
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
# 關閉proguard的優化和預檢功能,Dex後續會負責這些優化工作;
-dontoptimize
#什麼是預檢?class loader在加載class文件的時候會對byte code進行檢查,確保代碼不會對jvm造成危害;
#proguard也可以預檢,並將預檢信息加入class文件,於是,當class loader加載class的時候,就能加快速度和減少內存使用量了;
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.
# 保留註釋,這個看似是個通配符,其實不是,是保留所有的註釋,不管這個註釋叫什麼;
-keepattributes *Annotation*
# 暫時只知道和App發佈到谷歌商店的時候設置授權有關係
-keep public class com.google.vending.licensing.ILicensingService
-dontnote com.google.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
# 不要重命名包含native方法的類和方法;
-keepclasseswithmembernames class * {
native <methods>;
}
# Keep setters in Views so that animations can still work.
# Setters for listeners can still be removed.
# see http://proguard.sourceforge.net/manual/examples.html#beans
# 保留View的子類的這些setter和getter方法,動畫系統會調用;
-keepclassmembers public class * extends android.view.View {
void set*(%);
void set*(%, %);
void set*(%, %, %, %);
void set*(%[]);
void set*(**[]);
void set*(!**Listener);
% get*();
%[] get*();
**[] get*();
!**Listener get*();
}
# We want to keep methods in Activity that could be used in the XML attribute onClick.
# 保留Activity裏被layout裏的onClick屬性引用的方法;
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
# 保留枚舉類的values和valueOf方法;java編譯器會把enum轉成具有特殊結構的class,jvm是通過反射調用這個類的values()和valueOf()方法的;
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
# 保留Parcelable對象的static CREATOR域,這是Android用來反序列化對象的.由於CREATOR是在運行時被調用,所以如果不加規則,ProGuard會把它當成無用的成員直接去掉.
-keepclassmembers class * implements android.os.Parcelable {
public static final ** CREATOR;
}
# 保留R的內部類的public static域,app可能通過反射使用這些域;
-keepclassmembers class **.R$* {
public static <fields>;
}
# The support libraries contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
# 支持庫包含了對新版本platform的引用,在和舊的platform鏈接的時候會報錯,我們心裏有數,不要輸出通知和警告;
-dontnote android.support.**
-dontwarn android.support.**
# Understand the @Keep support annotation.
# 不要混淆Keep註釋類,這個註釋可能被用來修飾某些類,表示不要混淆;
# 所以說,我們有2個途徑實現不要混淆:1)proguard配置文件; 2)在java代碼裏使用@Keep註釋;
-keep class android.support.annotation.Keep
# 不要混淆由@Keep註釋的類,包括所有成員和方法;
-keep @android.support.annotation.Keep class * {*;}
# 不要混淆由@Keep註釋的方法及其所在的類;
-keepclasseswithmembers class * {
@android.support.annotation.Keep <methods>;
}
# 不要混淆由@Keep註釋的域及其所在的類;
-keepclasseswithmembers class * {
@android.support.annotation.Keep <fields>;
}
# 不要混淆由@Keep註釋的構造方法及其所在的類;
-keepclasseswithmembers class * {
@android.support.annotation.Keep <init>(...);
}
proguard-android.txt註釋
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Basic Android Interview Questions
letstalktech88
2021-06-01 18:54:25
聚焦市场开发热门技术 手把手带你开发商业级社交App
wy53780
2020-04-23 14:07:47
逆向美团外卖app__skcy算法
1939481097
2019-12-11 11:33:48
逆向淘宝x-sign算法
1939481097
2019-12-11 11:30:02
Android 原生app獲取用戶授權訪問Autodesk雲應用數據
樑曉冬
2019-02-24 23:44:12
Android平臺調用WebService詳解
推薦碼發放
2019-02-24 19:41:33
Android開發學習之使用Toolbar實現不同的Fragment使用不同顏色的標題欄與狀態欄
優惠券發放
2019-02-24 19:41:23
虹軟人臉識別ArcFace2.0 Android SDK使用教程
gsmd_cc
2019-02-24 19:04:27
爲什麼要做短視頻秒播優化
WalkerXu
2019-02-24 15:34:05
Android Architecture Components——Room
大熊啊啊啊
2019-02-24 14:08:54
Android高效安全加載圖片的方法詳解
我爱宋慧乔
2019-02-24 12:42:54
第二十二章:動畫(四)
wangccsy
2019-02-24 10:57:10
android入門系列
尋夢緣2008
2019-02-23 13:56:52