Search code examples
androidproguardandroid-proguard

Proguard obfuscates class despite -keepclasseswithmembernames


I try to prevent obfuscation for the classes which contains attribute @com.evernote.android.state.State on any members

For this i add to my rule:

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

And it doesn't work. Classes are obfuscated

But if specify more concrete condition:

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

It works fine!

Can somebody clarify why first variant doesn't work?

Build-gradle version is 3.1.2


Solution

  • The rule -keepclasseswithmembernames will match only if all specified members match. If you use a wildcard like *, then all fields and methods must be annotated, which is probably not the case.

    If you match only fields then it will work.