Android到Google App Engine序列化异常 [英] Android to Google App Engine serialization exception

查看:132
本文介绍了Android到Google App Engine序列化异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在android代码中序列化一个对象图并将结果传递给GAE servlet。反序列化时,我有时会得到以下异常:

java.io.StreamCorruptedException:无效类型代码:71

我将问题追溯到其中一个字段。如果我将其设置为空或标记为瞬态,则问题会消失。但是,如果我只序列化/反序列化这个字段 - 我也没有看到任何问题。



任何想法?

解决方案

我建议使用JSON或Google Protocol Buffers代替自己的序列化代码。
扩展和维护要容易得多。
XML也是一种选择,但它是序列化/反序列化最慢的,也是与JSON / protobuf相比最不紧凑的格式。


I'm serializing an object graph in the android code and pass result to GAE servlet. While deserializing I sometimes get the following exception:

java.io.StreamCorruptedException: invalid type code: 71

I traced the problem down to one of the fields. If I set it to null or mark as transient the problem disappears. But, if I serialize/deserialize only this field - I don't see any problems as well.

Any ideas?

解决方案

I suggest to use JSON or Google Protocol Buffers instead of own serialization code. It is much easier to extend and maintain. XML is also an option, but it is the slowest to serialize/deserialize and also the least compact format compared to JSON / protobuf.

这篇关于Android到Google App Engine序列化异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆