0

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!
Matthew Wright
  • 1,485
  • 1
  • 14
  • 38
  • Given that `org.jsoup` is a library and not part of your program, why would you try to obfuscate its code ? Jsoup is probably trying to load something reflectively there. Have you tried keeping this library jar as is ? – Deepak Bala Aug 04 '13 at 17:31
  • I had thought about keeping the jsoup library alone but I haven't tried that since I so far dont know how the prevent Proguard from leaving the jsoup library alone. (tried http://stackoverflow.com/questions/7721397/how-to-make-proguard-ignore-external-libraries loading a config to keep org.** for org.jsoup) and got the same result of spammed Console problem as above.) – Matthew Wright Aug 04 '13 at 17:39
  • The keep option should have worked. If it didn't it means something is amiss. Start with a really wide `-keep` rule just to check if things work and then narrow it down by each library package. That will isolate the problem. Btw what does `org.jsoup.b.l` map to ? – Deepak Bala Aug 04 '13 at 17:49
  • Your first comment was very helpful, apparently the config.txt changes the default config which was causing the spam problem. This is what I did (Obfuscation > Keep additional class names and class member names > add > Extends/Implements class = "org.jsoup.**" > ok ; To your question above I have no idea, it maps to something from jsoup which I cant tell being because of what you said before, that I was obfuscation the org.jsoup library. – Matthew Wright Aug 04 '13 at 17:51
  • Glad that it helped. My second question was aimed at finding if the said class used reflection. Please feel free to move your comment to the answers section and accept it. Others that stumble on this post later will find it useful. – Deepak Bala Aug 04 '13 at 19:40

0 Answers0