发布的apk显示了Objectmapper异常"禁用了SerializationFeature.FAIL_ON_EMPTY_BEANS"用于firebase数据库对象的发送

时间:2016-07-18 19:34:33

标签: android serialization firebase-realtime-database fasterxml objectmapper

  

我正在尝试实现firebase数据库以将类对象发送到数据库。在调试模式下,它工作正常但在Signed apk中,它显示以下错误。从数据库中解析数据非常容易。

     

堆栈追踪:

 FATAL EXCEPTION: main
                                               Process: com.xxxx.razon30.movietest, PID: 15017
                                               java.lang.IllegalArgumentException: No serializer found for class com.xxxx.razon30.movietest.af and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )
                                                   at com.fasterxml.jackson.databind.ObjectMapper._convert(Unknown Source)
                                                   at com.fasterxml.jackson.databind.ObjectMapper.convertValue(Unknown Source)
                                                   at com.example.razon30.movietest.fr.onClick(Unknown Source)
                                                   at android.view.View.performClick(View.java:5204)
                                                   at android.view.View$PerformClick.run(View.java:21153)
                                                   at android.os.Handler.handleCallback(Handler.java:739)
                                                   at android.os.Handler.dispatchMessage(Handler.java:95)
                                                   at android.os.Looper.loop(Looper.java:148)
                                                   at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                Caused by: com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class com.example.razon30.movietest.af and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )
                                                   at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(Unknown Source)
                                                   at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(Unknown Source)
                                                   at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(Unknown Source)
                                                   at com.fasterxml.jackson.databind.ObjectMapper._convert(Unknown Source) 
                                                   at com.fasterxml.jackson.databind.ObjectMapper.convertValue(Unknown Source) 
                                                   at com.example.razon30.movietest.fr.onClick(Unknown Source) 
                                                   at android.view.View.performClick(View.java:5204) 
                                                   at android.view.View$PerformClick.run(View.java:21153) 
                                                   at android.os.Handler.handleCallback(Handler.java:739) 
                                                   at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                   at android.os.Looper.loop(Looper.java:148) 
                                                   at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  

我的实际代码是:

 ClassReview classReview = new ClassReview(u_name, u_review, u_rat);
 myFirebaseRef.child(m_id).push().setValue(map);
  

我已经搜索了解决方案然后我得到了这个并应用了

 ClassReview classReview = new ClassReview(u_name, u_review, u_rat);
 ObjectMapper mapper = new ObjectMapper();
 Map<String, Object> map = mapper.convertValue(classReview, Map.class);
 myFirebaseRef.child(m_id).push().setValue(map);
  

但问题仍然存在。这是我对firebase的亲保护规则

-keepattributes Signature
-keepattributes *Annotation*
-keep class com.firebase.** { *; }
-keep class com.google.firebase.quickstart.database.viewholder.** {
*;
 }

-keepclassmembers class com.google.firebase.quickstart.database.models.**   {*;}
-keep  class com.fasterxml.** { *; }
-keep  class com.fasterxml.jackson.annotation.** {*;}
-keep  class com.fasterxml.jackson.core.** {*;}

0 个答案:

没有答案