How to negate classname with Proguard

别等时光非礼了梦想. 提交于 2021-01-28 06:24:29

问题


I want to be able to obfuscate only a subset of classes with proguard, but am having a hard time since proguard seems to designed primarily to obfuscate everything, except for a blacklist.

However, the proguard manual does say:

For additional flexibility, class names can actually be comma-separated lists of class names, with optional ! negators, just like file name filters. This notation doesn't look very Java-like, so it should be used with moderation.

but there are no examples of that.

I am trying this:

-keep class !**.licence.** {*;}
-keep class !**.*Licence*.** {*;}

but that does work. If I remove the !, the patterns themselves do work (everything else gets obfuscated, except the above). I have also tried with the method definitiones ({*;} removed), but still does not work.

Does anyone have any examples of negators on classnames? Is there another way to tell proguard to only obfuscate specific class/package patterns (without using in-code annotations)?


回答1:


I finally figured it out on my own. The negations must all be on one line, like this:

-keep class !ca.nanometrics.**.licence.**,!ca.nanometrics.**.*Licence*{*;}


来源:https://stackoverflow.com/questions/29474822/how-to-negate-classname-with-proguard

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