0

After dexguarding my application I got this error when running my application

01-01 04:47:02.948: E/AndroidRuntime(8125): FATAL EXCEPTION: Thread-9
01-01 04:47:02.948: E/AndroidRuntime(8125): java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilder.setEntityResolver
01-01 04:47:02.948: E/AndroidRuntime(8125):     at o.郋.櫯(:134)
01-01 04:47:02.948: E/AndroidRuntime(8125):     at o.郋.鷭(:82)
01-01 04:47:02.948: E/AndroidRuntime(8125):     at android.SHAREDLIBS.network.ISOManager.LoadISOXMLMessageFactory(:637)
01-01 04:47:02.948: E/AndroidRuntime(8125):     at o.Ț.run(:294)

Alright, no issues. Simply exclude that class from being obfuscated. But it doesn't matter what I try to include in the dexguard-project.txt file, I still keep getting the error.

A few things I've tried

  • -keep public class javax.xml.parsers.**
  • -keep public class javax.xml.parsers.DocumentBuilder
  • -keep public abstract class javax.xml.parsers.DocumentBuilder
  • -keep class javax.xml.parsers.DocumentBuilder.** { *; }
  • -keep public abstract class javax.xml.parsers.DocumentBuilder.** { *; }
  • -keep public class javax.xml.parsers.** { *; }
  • -keep public class javax.xml.parsers.DocumentBuilder.** {public private protected *;}
  • -keepclassmembers class javax.xml.parsers.DocumentBuilder { public abstract void setEntityResolver (org.xml.sax.EntityResolver); }
  • -keepclassmembers public abstract class javax.xml.parsers.DocumentBuilder { public abstract void setEntityResolver (org.xml.sax.EntityResolver); }

I am running it with the following flags.

-dontshrink
-dontoptimize

So obviously the issue is in the obfuscation step.

And yes, if I disable obfuscation, it works without any issues.

I am obviously doing something wrong because even after I explicitly requests to exclude it, I still keep getting the error.

Am I excluding it correctly ? Is there any other thing that looks wrong ?

Ranhiru Jude Cooray
  • 19,542
  • 20
  • 83
  • 128

2 Answers2

2

A NoSuchMethodException is caused by failing reflection. Keeping the method can then help. A NoSuchMethodError is caused by a linking problem. In this case, the code needs a method in the Android runtime. It may be caused by using incompatible libraries. The console log of ProGuard or DexGuard may contain some hints.

If you mail me your configuration, your build log, and your failing apk, at saikoa.com, I'll look into it.

(I am the creator of ProGuard and DexGuard)

Eric Lafortune
  • 45,150
  • 8
  • 114
  • 106
  • Hello Eric, I will unfortunately not be able to send you the APK because I do not have the permission to do so. I understand, that without it, you will not be able to give me a solid answer. Anyway can you tell me whether the way I am excluding the class in the config file is correct ? – Ranhiru Jude Cooray Oct 14 '13 at 01:46
  • -keep options won't help, because the processed code is looking for the method in the Android runtime, which is not affected by the processing. You should check the console output of the build process. Any pieces of information that you can mail me may help. We can also make sure that you have the latest update of DexGuard. – Eric Lafortune Oct 14 '13 at 09:04
1

I'm leaving my solution here in case it's of any help to anyone else - I know it's no longer of use to the person who asked the question.

In my case the DocumentBuilder was an instance of org.apache.harmony.xml.parsers.DocumentBuilderImpl so adding -keep class org.apache.** { *; } solved the issue.

My advise, when you get a similar error on and abstract class, is to log the instance of the object in order to find out which class you have to keep.

anemomylos
  • 546
  • 1
  • 6
  • 14