ProGuard difficulties when obfuscating with librar

2019-09-08 08:35发布

While trying to use ProGuard (4.9) to obfuscate and optimise a desktop application everything works up until I use something from an external library such as JSoup.connect("http://google.com/").get();. I would get the following error:

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

I have tried searching for a solution but the answer would always be for an android application. With no luck I have attempted the following:

  • Turn off Use mixed-class names
  • Added to config -keep public enum * { public static **[] values(); public static ** valueOf(java.lang.String); }

Recently, going through with this process using ProGuard 5.2, not much has changed. Here is the updated process to fixing the issue:

  1. Go to the Obfuscation tab.
  2. Go to the bottom for Keep additional class names and class member names
  3. Click on Add... to the right
  4. Go down to Extends/implements class and type in your library matching the examples below then press Ok. Repeat for every library.

    • For JSoup: org.jsoup.**
    • For Apache Commons Net: org.apache.commons.net.**
    • For SwingX: org.jdesktop.**
    • For GSON: org.google.gson.**
  5. Go to the Information tab.

  6. Turn off Skip non-public library class members
  7. Turn on Ignore warnings about possibly erroneous input
  8. Process!

0条回答
登录 后发表回答