[英]How to configure 'build_common.xml' Ant file for Proguard and ORMLite in java application
I have a Java application running on PC (Windows). 我有一个在PC(Windows)上运行的Java应用程序。 I use Netbeans. 我使用Netbeans。
I use Proguard to obfuscate the code and I configure the obfuscation by the build_common.xml (Ant) file; 我使用Proguard混淆代码,并通过build_common.xml(Ant)文件配置混淆; therefore the ProGuard configuration options are given by XML configuration tags. 因此,ProGuard配置选项由XML配置标签提供。 I'm not expert at all of Xml, Proguard, I just copied and adapted some pieces of codes got in the web for my purposes and it worked. 我不是Proml Xml方面的专家,我只是复制并改编了一些网络上的代码以达到我的目的,并且可以正常工作。
Recently I introduced in my code ORMLite. 最近,我在代码ORMLite中进行了介绍。 When I run from IDE (so without obfuscation) my code works, but when I build with obfuscation it doesn't work. 当我从IDE运行时(因此没有混淆),我的代码可以工作,但是当我进行混淆时,则无法工作。 Inside build_common.xml I excluded the "class com.j256.**" library, by: 在build_common.xml中,我通过以下方式排除了“类com.j256。**”库:
<keep name="com.**" > <method name="*" /> <field name="*" /> </keep>
but it isn't enought because probably ORMLite uses special annotations. 但这还不够,因为ORMLite可能使用了特殊的注释。
I found out some post, suggesting to use for example: 我发现了一些帖子,建议使用例如:
-keepattributes *DatabaseField*
-keepattributes *DatabaseTable*
-keepattributes *SerializedName*
-keep class com.j256.**
-keepclassmembers class com.j256.** { *; }
-keep enum com.j256.**
-keepclassmembers enum com.j256.** { *; }
-keep interface com.j256.**
-keepclassmembers interface com.j256.** { *; }
-dontwarn com.j256.ormlite.logger.**
-dontwarn com.j256.ormlite.misc.**
but I don't know how to write those options in XML; 但是我不知道如何用XML编写这些选项。 I did some trying but it didn't work. 我做了一些尝试,但是没有用。
Can anybody help? 有人可以帮忙吗? Moreover on how to exclude from obfuscation ORMLite annotations. 此外,还介绍了如何从混淆中排除ORMLite注释。
Founded out the solution: 找到解决方案:
simply added inside the proguard tags of 'build_common.xml' file the line: 只需在“ build_common.xml”文件的proguard标签内添加以下行:
-keepattributes *Annotation*
`the rest of the lines mensioned in my question seems unusefull 在我的问题中提到的其余内容似乎没有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.