Obfuscate private fields using ProGuard

后端 未结 1 387
无人共我
无人共我 2020-12-13 21:37

I\'m using ProGuard in AndroidStudio 1.2.1.1 with Gradle 1.2.3.

My Gradle\'s release build is configured like so:

minifyEnabled true
proguardFiles ge         


        
相关标签:
1条回答
  • 2020-12-13 21:52

    Getting from this: How to tell ProGuard to keep private fields without specifying each field

    According to ProGuard documenation the wildcard matches any field.

    Top of that, You can use negators (!). (http://proguard.sourceforge.net/#manual/usage.html)

    Attribute names can contain ?, *, and ** wildcards, and they can be preceded by the ! negator.

    I am not so experienced in this field, so rather it is a guess, but easier to write in a new comment. Something like this should do the job (NOT TESTED):

    -keepclassmembers class * { //should find all classes 
        !private <fields>;    
        <methods>;
        <init>; //and keep every field, method, constructor apart from private fields
    }
    

    May be you can use like this, but do not sure how it works with a negator first:

    -keepclassmembers class * { //should find all classes 
        !private <fields>;    
        *; //should exclude everything except private fields, which should be obfuscated.
    }
    
    0 讨论(0)
提交回复
热议问题