I have an Android project targeting API 17 which needs to consume a Jersey 2.4.1 REST service. However, at runtime I keep getting a NoClassDefFoundError for org.glassfish.jersey.model.internal.CommonConfig$1
. This class is in the Jersey JAR files I need for the client code.
I have followed instructions from other posts about the libs Android dependency fix e.g. Android java.lang.NoClassDefFoundError but I still get the issue. The JAR is in the libs dir and I have checked the export option in the build path. What's weird is I have other jersey jars in this lib which are working, it just doesn't seem to find this one.
I have tried cleaning the project, refreshing it, removing and re-adding the JAR but I just can't seem to get it working. The class it complains about is in the jersey-common-2.4.1.jar which I can see in the Eclipse workspace so the right JAR is there, just seems it's not being exported with the APK.
UPDATE
I tried configuring ProGuard to see what gets produced but it was a never ending rabbit hole of warnings about classes and methods. In the end I just put -ignorewarnings
in to get something output.
UPDATE2
I looked at the error message a little closer and it's actually missing org.glassfish.jersey.model.internal.CommonConfig$1
(note the $1). This is a static inner class which makes me almost certain that it's a ProGuard config issue. I tried adding:
-keepclasseswithmembers class org.glassfish.jersey.**
-keepclasseswithmembers class javax.ws.rs.**
to my proguard-project.txt file but I still get the NoClassDefFoundError. How can I tell Eclipse/ProGuard to leave my library jars alone completely for both kinds of build options (right click deploy and export)?
ANSWER/RESOLUTION
See my comment in response to @pjco.