Obfuscate private fields using ProGuard

試著忘記壹切 提交于 2019-11-30 02:00:53
czupe

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.
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!