java - ProGuard 破坏了 Java 应用程序——没有文本,没有图像

标签 java obfuscation proguard

我正在尝试使用 ProGuard混淆 Java 应用程序。我遇到了一个问题,我的所有文本和图像都从 GUI (Swing) 表单中消失了。我试过禁用优化并包含更多库,但似乎没有任何效果。

我用反编译器检查了混淆器生成的输出,我的资源路径似乎仍然是正确的。

  1. 我是否需要在 jre/lib/rt.jar 之外包含更多核心 Java 库?
  2. 我应该禁用更多设置吗?
  3. ...其他建议?

谢谢。

最佳答案

您的资源很可能是 (a) 当包含资源的包被混淆时,通过 ProGuard 正在更改的路径访问,或者 (b) 由于它们未复制到输出 JAR 而被丢弃。

您不需要在配置中明确包含 Java 运行时类。

您可能需要查看以下选项:

-adaptclassstrings [class_filter] Specifies that string constants that correspond to class names should be obfuscated as well. Without a filter, all string constants that correspond to class names are adapted. With a filter, only string constants in classes that match the filter are adapted. For example, if your code contains a large number of hard-coded strings that refer to classes, and you prefer not to keep their names, you may want to use this option. Primarily applicable when obfuscating, although corresponding classes are automatically kept in the shrinking step too.

-adaptresourcefilenames [file_filter] Specifies the resource files to be renamed, based on the obfuscated names of the corresponding class files (if any). Without a filter, all resource files that correspond to class files are renamed. With a filter, only matching files are renamed. For example, see processing resource files. Only applicable when obfuscating.

-adaptresourcefilecontents [file_filter] Specifies the resource files whose contents are to be updated. Any class names mentioned in the resource files are renamed, based on the obfuscated names of the corresponding classes (if any). Without a filter, the contents of all resource files updated. With a filter, only matching files are updated. The resource files are parsed and written using the platform's default character set. You can change this default character set by setting the environment variable LANG or the Java system property file.encoding. For an example, see processing resource files. Only applicable when obfuscating.

并查看 http://proguard.sourceforge.net/manual/examples.html#resourcefiles了解更多详情。

关于java - ProGuard 破坏了 Java 应用程序——没有文本,没有图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4965126/

相关文章:

java - 不读取文件

java - 尝试使用子类方法,但它不允许我

c - o-llvm(基于 llvm3.4)发出混淆代码

android - 不推荐使用 Progruard 和 R8 - Android Studio 3.6

android - Proguard 不剥离木材原木

java - 无法在android中实现描述符

java - JSON 到 Java : How to model lists of objects into generic object class whose object name from json is variable

java - 如何配置混淆器以将所有类保留在包名称中包含特定单词的包中?

asp.net - 如何使 ASP.NET HTML 代码对客户端(用户)不可见

java - Proguard 是否会删除仅在一处使用的方法? [方法内联]