我正在尝试用ProGuard优化/混淆java项目。我将该项目作为一个可运行的jar从eclipse中提取出来,它运行得很好。
当我尝试用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
显然,对于你们来说,这可能是一个太普遍的问题,无法修复,但是我可能会犯一些我没有意识到的明显的重大错误,这就是我要做的。
发布于 2016-09-24 06:59:12
注释只是建议,但警告指出了输入中的不一致之处。值得注意的是,13229个未解析的引用表明您提供的是应用程序的主要代码(使用-injars),而不是其库(使用-injars或-libraryjars)。我不知道Eclipse的提取或重新打包选项,但您应该检查输入jar的内容。
请参阅ProGuard手册>故障排除> Warning: can't find referenced class。
https://stackoverflow.com/questions/39645639
复制相似问题