proguard-android.txt註釋

# 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>(...);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章