json – How to fix IncompatibleClassChangeError during Android Jackson Parsing using annotations in Android Lollipop?-ThrowExceptions

Exception or error:

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)
How to solve:

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

Leave a Reply

Your email address will not be published. Required fields are marked *