我有一个包含10个图书馆项目和一个应用程序项目的Android应用程序。 其中2个库项目使用jackson库作为依赖项。这是来自build.gradle的两个snipet
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4'
compile 'com.fasterxml.jackson.core:jackson-core:2.4.4'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.4'
现在我的应用程序因以下异常而崩溃
at java.lang.Class.getDeclaredAnnotations(Native Method) at com.fasterxml.jackson.databind.introspect.AnnotatedClass.resolveClassAnnotations(AnnotatedClass.java:308) at com.fasterxml.jackson.databind.introspect.AnnotatedClass.getAnnotation(AnnotatedClass.java:173) at com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.isIgnorableType(JacksonAnnotationIntrospector.java:97) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.isIgnorableType(BeanDeserializerFactory.java:870) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.filterBeanProps(BeanDeserializerFactory.java:635) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:527) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:270) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:168) at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:399) at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:348) at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:261) at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:241) at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142) at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:394) at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:3169) at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3033) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1652)
在崩溃之前,我可以在日志中看到以下行
Class resolved by unexpected DEX: Lcom/vocalocity/Administration/api/support/extensionKit/ExtkitConfig;(0x41ac7088):0x7acd1000 ref [Lcom/fasterxml/jackson/annotation/JsonAutoDetect$Visibility;] Lcom/fasterxml/jackson/annotation/JsonAutoDetect$Visibility;(0x41ac7088):0x7a356000 (Lcom/vocalocity/Administration/api/support/extensionKit/ExtkitConfig; had used a different Lcom/fasterxml/jackson/annotation/JsonAutoDetect$Visibility; during pre-verification) Failed processing annotation value
我尝试使用
构建应用程序而不使用proguardminifyEnabled = false
然后它工作正常。但这不是一个选项,因为我需要对我的应用进行模糊处理。 我在我的proguard文件中尝试了以下内容。
-keep class com.fasterxml.jackson.** { *; }
-keepattributes *Annotation*
但它仍然会导致崩溃。 你能告诉我如何避免这次崩溃吗?