Proguard 混淆 class 尽管 -keepclasseswithmembernames

Proguard obfuscates class despite -keepclasseswithmembernames

我尝试防止对包含属性的 类 进行混淆 @com.evernote.android.state.State 任何成员

为此,我添加到我的规则中:

-keepclasseswithmembernames class * { @com.evernote.android.state.State *;}

而且它不起作用。 类 被混淆了

但如果指定更具体的条件:

-keepclasseswithmembernames class * { @com.evernote.android.state.State <fields>;}

效果很好!

有人可以澄清为什么第一个变体不起作用吗?

Build-gradle版本为3.1.2

仅当 所有 指定成员匹配时,规则 -keepclasseswithmembernames 才会匹配。如果你使用像*这样的通配符,那么所有的字段和方法都必须被注解,这很可能不是这样。

如果您只匹配字段,那么它将起作用。