ProGuard difficulties when obfuscating with libraries

烈酒焚心 提交于 2020-01-07 05:52:27

问题


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!

来源:https://stackoverflow.com/questions/18045587/proguard-difficulties-when-obfuscating-with-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!