Jude Cooray
Jude Cooray

Reputation: 19872

Excluding class on NoSuchMethodError does not work for DexGuard

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

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 ?

Upvotes: 0

Views: 1131

Answers (2)

anemomylos
anemomylos

Reputation: 641

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.

Upvotes: 1

Eric Lafortune
Eric Lafortune

Reputation: 45676

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)

Upvotes: 2

Related Questions