- Principle and goals see source code.
StrongKeep: neither be renamed, nor be deleted;WeakKeep: guarantee not be renamed, but without guarantee not be deleted;ReverseKeep: without guarantee not be renamed, but guarantee not be deleted;NonKeep: out of the rules above. Means apply proguard default.
- From high to low in the order: Strong, Weak, Reverse, Non. When be carried over into subclass/subinterface, subclass/subinterface got the same priority.
- Anywhere, if one name be annotated by some different priority but same function of "@KeepXxx"s, the higher one will be applied.
-
Contain char
$meansStrong Keep(exclude Reverse Keep). e.g: @Keep$; -
Does not contain chars above means
Weak Keep; -
Does not exist annotation definition of
Non Keep, means no need for annotate names;Equivalent: all Non Keep types, if any fields of the types be kept, the class names of types be Reverse Kept. -
End with
emeans the function indicated by the words before "e" will be carried over into subclass/subinterface. e.g: @KeepMp$e;Note that only when superclass/superinterface did not deleted on proguard task, subclass/subinterface may kept. Means must Strong/Reverse Keep superclass/superinterface first.
-
V:var, act on variables/fields; -
M:method, act on methods/functions; -
C:constructor, act on constructors; -
p:public (var/method, depend on another symbol isVorM). Does not contains means ignorepublic/private...; -
s:static (var/method, depend on another symbol isVorM). Does not contains meansnon static.More details see each doc of `@KeepXxx`.
- Any annotation in package **.anno.inject, if not be deleted on proguard task, will apply Reverse Keep on the names it act directly on.
- 由高到低依次为强、反、弱、不。被延续到子类(接口)的,子类享有相同优先级;
- 任何位置,若被不同优先级的注解同时标注,则会应用较高优先级。
-
不含以上标识字符的为
弱保留; -
没有用于
不保留的标签,即:不加任何标注则为不保留;等效性:所有不保留的类型,如果该类型的任一字段被保留了,则效果上该类型名被反保留。 -
另:以
e结尾的表示将其前面名称表达的功能延续到子类。如:@KeepMp$e。需要注意的是:只有父类(接口)没有被混淆删除的情况下,才能延续到子类。 即:首先需要将父类强保留或反保留。
-
V: var, 作用于成员变量或常量; -
M: method, 作用于方法或函数; -
C: constructor, 作用于构造方法; -
p: public (变量或方法,取决于组合的是V还是M)。没有本字符则表示忽略访问权限修饰; -
s: static (变量或方法,取决于组合的是V还是M)。没有则表示非static的。细节请参见各注解的源码文档。
- 对于包 **.anno.inject 中的任何注解,只要该注解没有被优化掉,就会对其直接作用的内容进行反保留。
import from jcenter repository use gradle script:
repositories {
jcenter()
}
dependencies {
// some code else ...
compile 'hobby.wei.c.anno:annoguard:1.0.0'
}
task genProguardConfigFile(type: UnZip ? ) {
// waiting for me please.
} #gradle配置中最好启用优化。即引用'proguard-android-optimize.txt'
#proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
-include libs/annotations.pro
#如果是以jar包的方式导入的而不是作为库项目,那么需要下面两行:#
-dontwarn hobby.wei.c.**
-libraryjars libs/annoguard-1.0.0.jar
-keep class com.google.gson.stream.** { *; }暂只给出代码中已有的部分示例链接,有任何问题或建议可 联系作者。