我的 android 应用程序出现运行时错误
Runtime error in my android app
每当我想在 jackson 对象映射器中包装一些数据时,我都会收到运行时错误并显示以下消息:
07-07 17:44:59.049 19642-20156/com.app.teamchannel E/AndroidRuntime:致命异常:SyncAdapterThread-1
java.lang.VerifyError: org/codehaus/jackson/map/ObjectMapper
我第一次遇到这个错误是在我在 gradle 中包含 google 分析之后,例如:
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)
终于找到解决办法了。明显是包名冲突,导致运行时取错类.
我做了什么:
我手动下载了两个 jar
- jackson-core-asl-1.9.3
- jackson-mapper-asl-1.9.13
并将两个库的包名称从 org.codehaus.jackson.** 更改为 custom.org.codehaus.jackson.@1。为了更改包名称,我使用了一个名为 JarJar.
的工具
您可以找到如何重新打包的说明 here。
之后,我将重新打包的 jar 放入您在应用程序文件夹中找到的 libs 文件夹中(Android Studio:项目视图)。
以下代码必须包含在 build.gradle 应用级别的依赖项中:
compile fileTree(include: ['*.jar'], dir: 'libs')
所以gradle也会在lib文件夹中编译jar。
每当我想在 jackson 对象映射器中包装一些数据时,我都会收到运行时错误并显示以下消息:
07-07 17:44:59.049 19642-20156/com.app.teamchannel E/AndroidRuntime:致命异常:SyncAdapterThread-1 java.lang.VerifyError: org/codehaus/jackson/map/ObjectMapper
我第一次遇到这个错误是在我在 gradle 中包含 google 分析之后,例如:
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)
终于找到解决办法了。明显是包名冲突,导致运行时取错类.
我做了什么:
我手动下载了两个 jar
- jackson-core-asl-1.9.3
- jackson-mapper-asl-1.9.13
并将两个库的包名称从 org.codehaus.jackson.** 更改为 custom.org.codehaus.jackson.@1。为了更改包名称,我使用了一个名为 JarJar.
的工具您可以找到如何重新打包的说明 here。
之后,我将重新打包的 jar 放入您在应用程序文件夹中找到的 libs 文件夹中(Android Studio:项目视图)。 以下代码必须包含在 build.gradle 应用级别的依赖项中:
compile fileTree(include: ['*.jar'], dir: 'libs')
所以gradle也会在lib文件夹中编译jar。