简体   繁体   English

如何告诉 Proguard 避免混淆 JNA 库类?

[英]How to tell Proguard to avoid obfuscating JNA library classes?

In other words: what -keep commands should I use to tell Proguard to avoid obfuscating my classes that represent native libraries?换句话说:我应该使用什么-keep命令来告诉 Proguard 避免混淆代表本机库的类? (since JNA requires that the names match the equivalent native function, struct, etc.) (因为 JNA 要求名称与等效的本机函数、结构等匹配)

This is the rule I'm using for now:这是我现在使用的规则:

-keepclassmembers class * extends com.sun.jna.** {
    <fields>;
    <methods>;
}

I still think there might be a better way to do it though.我仍然认为可能有更好的方法来做到这一点。

For me worked as well对我来说也有效

-keep class com.sun.jna.** { *; }
-keep class * implements com.sun.jna.** { *; }

I think I solved it using these rules instead, because it seems they need everything of the package to be de-obfuscated:我想我改用这些规则解决了它,因为他们似乎需要对包的所有内容进行去混淆:

-keep class com.sun.jna.** { *; }
-keep class * implements com.sun.jna.** { *; }

JNA by default uses Library interface method names to look up native function names. JNA 默认使用库接口方法名称来查找本机函数名称。 Anything other than those should be able to withstand obfuscation.除了这些之外的任何东西都应该能够经受住混淆。

If your tests include coverage of all JNA calls then you should be able to test this almost as fast as asking the question here.如果您的测试包括所有 JNA 调用的覆盖范围,那么您应该能够像在这里提出问题一样快速地进行测试。

EDIT编辑

Consider this a comment, since I'm not prepared to offer "-keep" commands :)将此视为评论,因为我不准备提供“-keep”命令:)

You certainly must avoid elimination or reordering of any Structure fields.您当然必须避免消除或重新排序任何结构字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM