2016-09-22 163 views
0

我想用ProGuard优化/混淆Java项目。 我从eclipse中将该项目解压缩为一个可运行jar,并且运行得很好。未能用ProGuard混淆Java代码

当我尝试使用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. 

我在项目中使用的外部库是在出口它入瓶中从日食。 (“将所需的库提取到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; 

难道我fondamentally错在这里做什么?

我已经试过没有成功的proguard的建议,我的代码编译在eclipse中没有任何警告。

这是一个非常大的项目,所以我不能真正提供一个MCVE,但如果有人能指出我在正确的方向在这里,我失去了什么,我真的很感激它。

警告的例子:(它继续为每一个方法)

http://pastebin.com/m9hX9LJA

显然,这可能是过于笼统的问题为你们解决,但是我可能会做一些重大明显我没有意识到的错误,这就是我要做的。

回答

0

注意事项只是建议,但警告指出输入内容不一致。值得注意的是,13229未解决的参考文献提示您提供应用程序的主代码(使用-injars),但不提供它的库(使用-injars或-libraryjars)。我不知道Eclipse的Extract或Repack选项,但您应该检查输入jar的内容。

请参阅ProGuard手册>故障排除>Warning: can't find referenced class