每当我想在jackson对象映射器中包装一些数据时,我收到运行时错误,并显示以下消息:
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
我第一次遇到这个错误是因为我在gradle中包含谷歌分析,如:
compile 'com.google.android.gms:play-services-analytics:8.4.0'
有人可以帮忙吗?到目前为止,我已经花了几个小时没有解决方案。
完成例外:
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)
答案 0 :(得分:0)
最后我找到了解决方案。显然有一个包名冲突,导致在运行时使用错误的类。
我做了什么:
我手动下载了两个罐子
并将包名称从org.codehaus.jackson。**更改为两个库的custom.org.codehaus.jackson。@ 1。要更改包名称,我使用了一个名为JarJar的工具。
您可以找到如何重新包装here的说明。
之后我将重新包装的jar放入你在app文件夹(Android Studio:项目视图)中找到的libs文件夹中。 以下代码必须包含在依赖项中app-level的build.gradle中:
compile fileTree(include: ['*.jar'], dir: 'libs')
因此gradle还会在lib文件夹中编译jar。