简体   繁体   English

Proguard对JAR文件的混淆

[英]Proguard Obfuscation for JAR files

I know how to obfuscate executable jar files due to the fact that it has a main class. 我知道如何混淆可执行的jar文件,因为它具有一个主类。 But I'm trying to create my API (It's already done) and I just need to obfuscate the code. 但是我正在尝试创建我的API(已经完成),我只需要混淆代码即可。 The problem is that whenever I try obfuscate the jar file using Proguard (A well known java obfuscator) it gives me an error about something to do with the 'keep'. 问题是,每当我尝试使用Proguard(一个著名的Java模糊处理器)对jar文件进行模糊处理时,都会给我关于与“保持”有关的错误。 I am running the proguard-gui from Proguard and in Eclipse, I exported the project as a normal jar file (not executable) and I'm trying to obfuscate that jar file. 我从Proguard运行proguard-gui,在Eclipse中,我将项目导出为普通的jar文件(不是可执行文件),并且试图混淆该jar文件。 Also, I am not including the .classpath and .project files inside my jar file either. 另外,我的jar文件中也没有包含.classpath和.project文件。 If anyone could please help/guide me in obfuscating non-executable jar files in Proguard, it would be very useful and appreciated. 如果有人可以帮助/指导我混淆Proguard中不可执行的jar文件,它将非常有用并受到赞赏。 Thank you. 谢谢。

Note: I'm using Proguard's GUI to obfuscate, not anything to do with the command line. 注意:我正在使用Proguard的GUI进行模糊处理,与命令行无关。

Image of problem: 问题图片: 在此处输入图片说明

In your config file for Proguard, you need to specify which classes you want to keep, otherwise Proguard will just reduce away everything. 在Proguard的配置文件中,您需要指定要保留的类,否则Proguard只会减少所有内容。 The most common kind of keep line looks something like: 最常见的保持线如下所示:

-keep my.applications.package.*

or 要么

-keep my.applications.package.MainClass

You can find examples of configuration files on the Proguard webpage 您可以在Proguard网页上找到配置文件的示例

Cfr ProGuard manual > Examples > A typical library Cfr ProGuard手册>示例> 典型库

The GUI has a checkbox for processing libraries. GUI具有用于处理库的复选框。

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

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