• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps NoClassDefFoundError for static inner class in library jar

ross3166

Lurker
I have a thread on StackOverflow (titled: NoClassDefFoundError for Jersey 2.4.1 client in Android) but I thought I would reach out here in hope of getting a more specific/targeted audience group.

I have followed instructions from other posts about the libs Android dependency fix but I still get the issue.

I am using Eclipse Juno, with an Android App targeting API 17. Basically I am getting a NoClassDefFoundError at runtime for the org.glassfish.jersey.model.internal.CommonConfig$1 class located in jersey-client-2.4.1.jar. This is when I just do a Run As... deploy from within Eclipse and it fails when I instantiate the CommonConfig class or one that depends on it internally. The start up log is given below:

[HIGH]12-10 12:25:20.657: I/dalvikvm(10170): Failed resolving Lorg/glassfish/jersey/model/internal/CommonConfig$1; interface 920 'Lcom/google/common/base/Function;'
12-10 12:25:20.657: W/dalvikvm(10170): Link of class 'Lorg/glassfish/jersey/model/internal/CommonConfig$1;' failed
12-10 12:25:20.657: E/dalvikvm(10170): Could not find class 'org.glassfish.jersey.model.internal.CommonConfig$1', referenced from method org.glassfish.jersey.model.internal.CommonConfig.<clinit>
12-10 12:25:20.657: W/dalvikvm(10170): VFY: unable to resolve new-instance 2031 (Lorg/glassfish/jersey/model/internal/CommonConfig$1;) in Lorg/glassfish/jersey/model/internal/CommonConfig;
12-10 12:25:20.657: D/dalvikvm(10170): VFY: replacing opcode 0x22 at 0x000c
12-10 12:25:20.657: W/dalvikvm(10170): VFY: unable to find class referenced in signature (Lcom/google/common/base/Predicate;)
12-10 12:25:20.657: W/dalvikvm(10170): VFY: unable to find class referenced in signature (Lcom/google/common/base/Predicate;)
12-10 12:25:20.657: I/dalvikvm(10170): Could not find method com.google.common.collect.Sets.newIdentityHashSet, referenced from method org.glassfish.jersey.model.internal.CommonConfig.<init>
12-10 12:25:20.657: W/dalvikvm(10170): VFY: unable to resolve static method 7321: Lcom/google/common/collect/Sets;.newIdentityHashSet ()Ljava/util/Set;
12-10 12:25:20.657: D/dalvikvm(10170): VFY: replacing opcode 0x71 at 0x002d
12-10 12:25:20.657: I/dalvikvm(10170): Could not find method com.google.common.collect.Lists.newLinkedList, referenced from method org.glassfish.jersey.model.internal.CommonConfig.<init>
12-10 12:25:20.657: W/dalvikvm(10170): VFY: unable to resolve static method 7309: Lcom/google/common/collect/Lists;.newLinkedList (Ljava/lang/Iterable;)Ljava/util/LinkedList;
12-10 12:25:20.657: D/dalvikvm(10170): VFY: replacing opcode 0x71 at 0x002e
12-10 12:25:20.657: I/dalvikvm(10170): Could not find method com.google.common.collect.Sets.newIdentityHashSet, referenced from method org.glassfish.jersey.model.internal.CommonConfig.asNewIdentitySet
12-10 12:25:20.657: W/dalvikvm(10170): VFY: unable to resolve static method 7321: Lcom/google/common/collect/Sets;.newIdentityHashSet ()Ljava/util/Set;
12-10 12:25:20.657: D/dalvikvm(10170): VFY: replacing opcode 0x71 at 0x0000
12-10 12:25:20.657: I/dalvikvm(10170): Could not find method com.google.common.collect.Sets.newIdentityHashSet, referenced from method org.glassfish.jersey.model.internal.CommonConfig.configureBinders
12-10 12:25:20.657: W/dalvikvm(10170): VFY: unable to resolve static method 7321: Lcom/google/common/collect/Sets;.newIdentityHashSet ()Ljava/util/Set;
12-10 12:25:20.657: D/dalvikvm(10170): VFY: replacing opcode 0x71 at 0x0000
12-10 12:25:20.657: W/dalvikvm(10170): VFY: unable to find class referenced in signature (Lcom/google/common/base/Predicate;)
12-10 12:25:20.657: I/dalvikvm(10170): Could not find method com.google.common.collect.Collections2.transform, referenced from method org.glassfish.jersey.model.internal.CommonConfig.getBinders
12-10 12:25:20.657: W/dalvikvm(10170): VFY: unable to resolve static method 7306: Lcom/google/common/collect/Collections2;.transform (Ljava/util/Collection;Lcom/google/common/base/Function;)Ljava/util/Collection;
12-10 12:25:20.657: D/dalvikvm(10170): VFY: replacing opcode 0x71 at 0x000a
12-10 12:25:20.657: I/dalvikvm(10170): Failed resolving Lorg/glassfish/jersey/model/internal/CommonConfig$1; interface 920 'Lcom/google/common/base/Function;'
12-10 12:25:20.657: W/dalvikvm(10170): Link of class 'Lorg/glassfish/jersey/model/internal/CommonConfig$1;' failed
12-10 12:25:20.657: I/dalvikvm(10170): Failed resolving Lorg/glassfish/jersey/model/internal/CommonConfig$1; interface 920 'Lcom/google/common/base/Function;'
12-10 12:25:20.657: W/dalvikvm(10170): Link of class 'Lorg/glassfish/jersey/model/internal/CommonConfig$1;' failed
12-10 12:25:20.665: I/dalvikvm(10170): Failed resolving Lorg/glassfish/jersey/model/internal/CommonConfig$1; interface 920 'Lcom/google/common/base/Function;'
12-10 12:25:20.665: W/dalvikvm(10170): Link of class 'Lorg/glassfish/jersey/model/internal/CommonConfig$1;' failed
12-10 12:25:20.665: D/dalvikvm(10170): DexOpt: unable to opt direct call 0x3860 at 0x0e in Lorg/glassfish/jersey/model/internal/CommonConfig;.<clinit>
12-10 12:25:20.665: I/dalvikvm(10170): Failed resolving Lorg/glassfish/jersey/model/internal/CommonConfig$2; interface 924 'Lcom/google/common/base/Predicate;'
12-10 12:25:20.665: W/dalvikvm(10170): Link of class 'Lorg/glassfish/jersey/model/internal/CommonConfig$2;' failed
12-10 12:25:20.665: D/dalvikvm(10170): DexOpt: unable to opt direct call 0x3863 at 0x10 in Lorg/glassfish/jersey/model/internal/CommonConfig;.getBinders
12-10 12:25:20.665: W/dalvikvm(10170): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lorg/glassfish/jersey/model/internal/CommonConfig;
12-10 12:25:20.665: W/dalvikvm(10170): threadid=24: thread exiting with uncaught exception (group=0x411492a0)[/HIGH]

It doesn't seem to find a static inner class of CommonConfig. In the SO forum I tinkered with some options in ProGuard but I've come to learn that this isn't even used in the standard debug mode, only when you do a release build (Export from Eclipse). It would appear that something is happening with the class but I can't figure out why it would not be included if its parent is. Is there some kind of 'light' ProGuard process that goes on when a debug deploy is done?

Any ideas on how to resolve this particular case of NoClassDefFoundError?
 
have you tried project > clean?

looks like a corrupted build to me.

...
also what instructions did you follow, can you link the stack overflow question? Maybe I can better answer you there.
 
Hey,
Yeah I've tried clean a bunch of times. The stack overflow question is given below:

NoClassDefFoundError for Jersey 2.4.1 client in Android - Stack Overflow

Interestingly, I tried to create fresh android project with nothing in it but one default hello world Activity. The vanilla application deploys successfully, then I add the offending JAR, update libs and dependencies etc and deploy again - get NoClassDefFoundError but on the CommonConfig class as a whole, not on the $1 class. So weird, it just does not like this JAR.

I've attached it for reference in case anyone wants to have a go at it. Had to change the extension to .zip to upload it but you can just download it and change it to .jar.

Just put a line of code somewhere like: CommonConfig conf = new CommonConfig(null);

Thanks
 

Attachments

I have worked out in the end that the problem was dependencies, and not having all classes that was needed by the jar. See my resolution in the Stack Overflow thread.
 
Back
Top Bottom