【问题标题】:Failing to obfuscate Java code with ProGuard无法使用 ProGuard 混淆 Java 代码
【发布时间】:2016-09-22 17:46:07
【问题描述】:

我正在尝试使用 ProGuard 优化/混淆 Java 项目。 我从 Eclipse 中将项目提取为一个可运行的 jar,它运行得很好。

当我尝试使用 ProGuard 对其进行压缩时,我收到了数以千计的警告和错误,尤其是在结尾处:

Note: there were 1 classes trying to access generic signatures using reflection.
      You should consider keeping the signature attributes
      (using '-keepattributes Signature').

Note: there were 14 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.
Note: there were 2 class casts of dynamically created class instances.
      You might consider explicitly keeping the mentioned classes and/or
      their implementations (using '-keep').

Note: there were 15 accesses to class members by means of introspection.
      You should consider explicitly keeping the mentioned class members
      (using '-keep' or '-keepclassmembers').

Warning: there were 13229 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
Warning: there were 61 instances of library classes depending on program classes.
         You must avoid such dependencies, since the program classes will
         be processed, while the library classes will remain unchanged.
Warning: there were 18 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile the code.

我在项目中使用的外部库在从 Eclipse 导出时添加到 jar 中。 (“将所需的库提取到 jar 中”)。我没有使用“repack into jar”选项,因为它确实减慢了 jar 的速度。

具体的库是:

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

我在这里做错了什么吗?

我尝试了proguard的建议但没有成功,我的代码在eclipse中编译没有警告。

这是一个非常大的项目,所以我不能真正提供 MCVE,但如果有人能在这里指出我所缺少的正确方向,我将非常感激。

警告示例:(它适用于每个方法)

http://pastebin.com/m9hX9LJA

显然这对于​​你们来说可能是一个太笼统的问题,但我可能会犯一些我没有意识到的重大明显错误,这就是我要解决的问题。

【问题讨论】:

    标签: java optimization jar proguard executable-jar


    【解决方案1】:

    注释只是建议,但警告指出输入中的不一致。值得注意的是,13229 个未解决的引用表明您正在提供应用程序的主要代码(使用 -injars),而不是它的库(使用 -injars 或 -libraryjars)。我不知道 Eclipse 的 Extract 或 Repack 选项,但您应该检查输入 jar 的内容。

    请参阅 ProGuard 手册 > 疑难解答 > Warning: can't find referenced class

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-10
      • 2013-02-22
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      相关资源
      最近更新 更多