whenever I want to wrapp some data in a jackson object mapper, I got a runtime error with following message:
07-07 17:44:59.049 19642-20156/com.app.teamchannel E/AndroidRuntime: FATAL EXCEPTION: SyncAdapterThread-1 java.lang.VerifyError: org/codehaus/jackson/map/ObjectMapper
First time I encountered this error was after I included google analytics in gradle like:
compile 'com.google.android.gms:play-services-analytics:8.4.0'
Can anyone help please? I've already spent couple of hours with no solution until now.
Complete exception:
Could not find class 'org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector', referenced from method org.codehaus.jackson.map.ObjectMapper. Could not find class 'org.codehaus.jackson.map.deser.StdDeserializerProvider', referenced from method org.codehaus.jackson.map.ObjectMapper. Could not find class 'org.codehaus.jackson.util.TokenBuffer', referenced from method org.codehaus.jackson.map.ObjectMapper._convert Could not find class 'org.codehaus.jackson.map.deser.StdDeserializationContext', referenced from method org.codehaus.jackson.map.ObjectMapper._createDeserializationContext Could not find class 'org.codehaus.jackson.util.DefaultPrettyPrinter', referenced from method org.codehaus.jackson.map.ObjectMapper._defaultPrettyPrinter FATAL EXCEPTION: SyncAdapterThread-1 java.lang.VerifyError: org/codehaus/jackson/map/ObjectMapper at com.app.teamchannel.adapters.MySyncAdapter.onPerformSync(MySyncAdapter.java:2205) at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:247) FATAL EXCEPTION: SyncAdapterThread-1 java.lang.VerifyError: org/codehaus/jackson/map/ObjectMapper at com.app.teamchannel.adapters.MySyncAdapter.onPerformSync(MySyncAdapter.java:2205) at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:247)
Finally I found a solution. There was obviously a package name collision, what lead to take the wrong classes during runtime.
What I did:
I downloaded both jars manually
and changed the package name from org.codehaus.jackson.** to custom.org.codehaus.jackson.@1 for both libraries. To change the package name I used a tool called JarJar.
You can find instructions how to repackage here.
After that I put the repackaged jars into libs folder which you find in app folder (Android Studio: project view). Following code must be included in the build.gradle on app-level in the dependencies:
compile fileTree(include: ['*.jar'], dir: 'libs')
So gradle also compiles jars in the lib folder.