更新时间:2023-11-26 09:31:52
从中得到:
如何告诉ProGuard保留私有字段而不指定每个字段
根据 ProGuard文档,通配符匹配任何
字段。
According to ProGuard documenation the wildcard matches any field.
最重要的是,你可以使用否定符(!)。
( http://proguard.sourceforge.net/#manual/usage.html )
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.
}