使用库进行混淆时,ProGuard会遇到困难

时间:2013-08-04 17:28:28

标签: java jsoup proguard

在尝试使用ProGuard(4.9)对桌面应用程序进行模糊处理和优化时,所有操作都会有效,直到我使用外部库(例如JSoup.connect("http://google.com/").get();)中的内容。我会收到以下错误:

Exception in thread "Thread-2" java.lang.ExceptionInInitializerError
    at org.jsoup.b.l.<clinit>(Unknown Source)
    at org.jsoup.b.f.<init>(Unknown Source)
    at org.jsoup.b.e.<init>(Unknown Source)
    at org.jsoup.c.bh.b(Unknown Source)
    at org.jsoup.c.bh.a(Unknown Source)
    at org.jsoup.c.b.a(Unknown Source)
    at org.jsoup.c.D.a(Unknown Source)
    at org.jsoup.a.a.a(Unknown Source)
    at org.jsoup.a.i.e(Unknown Source)
    at org.jsoup.a.e.a(Unknown Source)
    at package.a.a(Unknown Source)
    at package.a.b(Unknown Source)
    at package.w.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(Unknown Source)
    at java.util.Properties.load0(Unknown Source)
    at java.util.Properties.load(Unknown Source)
    at org.jsoup.b.k.d(Unknown Source)
    at org.jsoup.b.k.<clinit>(Unknown Source)
    ... 14 more

我试过寻找解决方案,但答案总是针对Android应用程序。没有运气,我尝试了以下内容:

  • 关闭Use mixed-class names
  • 已添加到配置-keep public enum * { public static **[] values(); public static ** valueOf(java.lang.String); }

最近,使用ProGuard 5.2完成此过程,并未发生太大变化。以下是修复问题的更新过程:

  1. 转到混淆选项卡。
  2. 转到Keep additional class names and class member names
  3. 的底部
  4. 点击右侧的Add...
  5. 转到Extends/implements class并输入与下面示例匹配的图书馆,然后按Ok。对每个库重复。

    • 对于JSoup:org.jsoup.**
    • 对于Apache Commons Net:org.apache.commons.net.**
    • 对于SwingX:org.jdesktop.**
    • 对于GSON:org.google.gson.**
  6. 转到“信息”标签。

  7. 关闭Skip non-public library class members
  8. 开启Ignore warnings about possibly erroneous input
  9. 过程!

0 个答案:

没有答案