如何使用Proguard否定类名 [英] How to negate classname with Proguard

查看:107
本文介绍了如何使用Proguard否定类名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够仅使用proguard来混淆一类类,但是由于proguard似乎主要是为了混淆除黑名单以外的所有内容,因此我很难过.

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.

但是, proguard手册确实说:

为获得更大的灵活性,类名实际上可以是用逗号分隔的类名列表,并带有可选的!否定符,就像文件名过滤器一样.这种表示法看起来不太像Java,因此应适度使用.

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.

,但没有任何示例.

我正在尝试:

-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.

有人在类名上有否定词的例子吗?有没有其他方法可以告诉Proguard仅混淆特定的类/程序包模式(不使用代码内注释)?

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)?

推荐答案

我终于自己弄清楚了.求反必须全部在一行上,像这样:

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*{*;}

这篇关于如何使用Proguard否定类名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆