简体   繁体   English

如何在Java应用程序中为Proguard和ORMLite配置'build_common.xml'Ant文件

[英]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.

相关问题 ANT:如何从Java调用ANT build.xml文件 - ANT :How to call ANT build.xml file from Java Java:如何使用自定义Ant build.xml将ProGuard集成到Jar项目中 - Java: How to integrate ProGuard in Jar Project using custom Ant build.xml 如何为ANT build.xml文件设置环境变量? (JAVA) - How to set environment variables for ANT build.xml file? (Java) 如何在ant build.xml中将Java文件视为资源 - How to treat java file as resources in ant build.xml 如何通过build.xml为多模块Java Ant项目配置Sonarqube - How to configure Sonarqube for multi module Java Ant project through build.xml 无法使用ant build.xml文件构建Webdriver Java代码 - Not able to build webdriver java code with ant build.xml file 如何为Ant构建配置Ivy - How to configure Ivy for Ant build 如何将Ant文件(build.xml)中的属性提取到Java代码中 - How to extract properties from Ant file (build.xml) into Java code 如何在使用build.xml文件的Ant生成的jar文件中包含Eclipse项目的“Java Build Path”部分中引用的jar文件 - How to include the jars referenced in “Java Build Path” section of an Eclipse project in a jar file generated with Ant using a build.xml file 如何为现有Java项目创建ant构建器文件(build.xml)? - How do I create an ant builder file (build.xml) for an existing Java project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM