jackson UnrecognizedPropertyException - proguard 缩小错误配置
jackson UnrecognizedPropertyException - proguard minification misconfig
调试 buildtype 工作正常,但生产(使用 proguard 和缩小)抛出异常
Caused by com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "timestamp" (class com.two_two.checkreaction.models.firebase.FireComplexResult), not marked as ignorable (0 known properties: ])
at [Source: java.io.StringReader@42256aa8; line: 1, column: 27] (through reference chain: com.two_two.checkreaction.models.firebase.FireComplexResult["timestamp"])
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:555)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:708)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1160)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:315)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2888)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2034)
at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:183)
at com.firebase.ui.FirebaseListAdapter.getView(FirebaseListAdapter.java:130)
at android.widget.AbsListView.obtainView(AbsListView.java:2338)
at android.widget.ListView.makeAndAddView(ListView.java:1812)
Firebase 的 Proguard 部分如下
# Basic ProGuard rules for Firebase Android SDK 2.0.0+
-keep class com.firebase.** { *; }
-keep class org.apache.** { *; }
-keep class com.two_two.checkreaction.models.firebase.FireComplexResult
-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class javax.servlet.** { *; }
-keepnames class org.ietf.jgss.** { *; }
-dontwarn org.apache.**
-dontwarn org.w3c.dom.**
# Firebase-UI
#-keepnames class com.firebase.ui.** { *; }
#-keep class com.firebase.ui.** { *; }
-dontwarn com.firebase.ui.**
更新:
-keep class com.two_two.checkreaction.models.firebase.** { *; }
解决问题。但是我不想保留包裹,我只想保留一个 class.
我在使用 Firebase 的应用程序中抛出了类似的异常。通过将我的 POJO 移动到一个包中并排除该包被此混淆规则混淆来解决它
-keepnames class com.my.package.beans.** { *; }
调试 buildtype 工作正常,但生产(使用 proguard 和缩小)抛出异常
Caused by com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "timestamp" (class com.two_two.checkreaction.models.firebase.FireComplexResult), not marked as ignorable (0 known properties: ])
at [Source: java.io.StringReader@42256aa8; line: 1, column: 27] (through reference chain: com.two_two.checkreaction.models.firebase.FireComplexResult["timestamp"])
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:555)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:708)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1160)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:315)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2888)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2034)
at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:183)
at com.firebase.ui.FirebaseListAdapter.getView(FirebaseListAdapter.java:130)
at android.widget.AbsListView.obtainView(AbsListView.java:2338)
at android.widget.ListView.makeAndAddView(ListView.java:1812)
Firebase 的 Proguard 部分如下
# Basic ProGuard rules for Firebase Android SDK 2.0.0+
-keep class com.firebase.** { *; }
-keep class org.apache.** { *; }
-keep class com.two_two.checkreaction.models.firebase.FireComplexResult
-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class javax.servlet.** { *; }
-keepnames class org.ietf.jgss.** { *; }
-dontwarn org.apache.**
-dontwarn org.w3c.dom.**
# Firebase-UI
#-keepnames class com.firebase.ui.** { *; }
#-keep class com.firebase.ui.** { *; }
-dontwarn com.firebase.ui.**
更新:
-keep class com.two_two.checkreaction.models.firebase.** { *; }
解决问题。但是我不想保留包裹,我只想保留一个 class.
我在使用 Firebase 的应用程序中抛出了类似的异常。通过将我的 POJO 移动到一个包中并排除该包被此混淆规则混淆来解决它
-keepnames class com.my.package.beans.** { *; }