How to fix IncompatibleClassChangeError during Android Jackson Parsing using annotations in Android Lollipop?

╄→гoц情女王★ 提交于 2020-06-24 08:05:38

问题


In our android app, we use Jackson Annotations in our models:

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "templateType", visible = true, defaultImpl = Default.class)
@JsonSubTypes({
@Type(value = Subclass1.class, name = "tType1")

We parse the json response using object mapper where klass is the class of the object file which we wish to parse to: getObjectMapper().readValue(json, klass);

On rare scenarios on Android Lollipop devices, we get

java.lang.IncompatibleClassChangeError: Couldn't find com.fasterxml.jackson.annotation.JsonSubTypes$Type.value.

Full stack trace:

com.fasterxml.jackson.annotation.JsonSubTypes$Type.value
at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:659)
at java.lang.Class.getDeclaredAnnotations(Class.java:891)
at com.fasterxml.jackson.databind.introspect.AnnotatedClass.resolveClassAnnotations(AnnotatedClass.java:300)
at com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.isIgnorableType(JacksonAnnotationIntrospector.java:103)
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.isIgnorableType(BeanDeserializerFactory.java:844)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:401)
at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:305)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:151)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.findDeserializer(StdDeserializer.java:634)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:438)
at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:173)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:99)
at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:106)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:464)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:98)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:295)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2888)

回答1:


This is a confirmed bug on some Samsung devices. Unfortunately there is no fix yet, but this Android Bug Tracker thread will probably come up with a fix (if possible) soon:

https://code.google.com/p/android/issues/detail?id=172339



来源:https://stackoverflow.com/questions/29619052/how-to-fix-incompatibleclasschangeerror-during-android-jackson-parsing-using-ann

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!