New Syntax to Config Proguard
base on @Annotation
Strong
Keep
: neither be renamed, nor be deleted;Weak
Keep
: guarantee not be renamed, but without guarantee not be deleted;Reverse
Keep
: without guarantee not be renamed, but guarantee not be deleted;Non
Keep
: out of the rules above. Means apply proguard default.Priority
Appoint
Contain char $
means Strong 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 e
means 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.
Symbols in the end of
@KeepXxx
, means the target places the annotation act on.
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 is V
or M
). Does not contains means ignore public/private...
;
s
:static (var/method, depend on another symbol is V
or M
). Does not contains means non static
.
More details see each doc of `@KeepXxx`.
Else
优先级
符号约定
不含以上标识字符的为弱保留
;
没有用于不保留
的标签,即:不加任何标注则为不保留;
等效性:所有不保留的类型,如果该类型的任一字段被保留了,则效果上该类型名被反保留。
另:以e
结尾的表示将其前面名称表达的功能延续到子类。如:@KeepMp$e。
需要注意的是:只有父类(接口)没有被混淆删除的情况下,才能延续到子类。
即:首先需要将父类强保留或反保留。
类名
@KeepXxx
后面的其它字母符号,表示其作用的目标位置。
V
: var, 作用于成员变量或常量;
M
: method, 作用于方法或函数;
C
: constructor, 作用于构造方法;
p
: public (变量或方法,取决于组合的是V
还是M
)。没有本字符则表示忽略访问权限修饰;
s
: static (变量或方法,取决于组合的是V
还是M
)。没有则表示非static的。
细节请参见各注解的源码文档。
其它
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.
}
proguard-rules.pro
(或其他名称)的开头加入下列代码:
#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.** { *; }
@KeepXxx
注解。暂只给出代码中已有的部分示例链接,有任何问题或建议可 联系作者。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。