2011-02-16 45 views
3

我尝试在Android上使用Gson来解释/取消整理JAXB注释类。从内省类注释中停止Gson

Android设备上未提供JAXB(XML)注释,因此JSON库不得检查注释 - 否则我们会遇到java.lang.NoClassDefFoundError: javax.xml.bind.annotation.XmlElement

我有相同的problem使用Jackson但似乎是fixed(感谢StaxMan)。因为我不知道什么时候该修复程序将被释放我认为GSON将是一个选择,因为这个文件声明的更多信息:

There is no need to use any annotations to indicate a field is to be included 
for serialization and deserialization. All fields in the current class (and 
from all super classes) are included by default.

不幸的是我仍然遇到这个问题:

ERROR/AndroidRuntime(338): java.lang.NoClassDefFoundError: javax.xml.bind.annotation.XmlElement 
ERROR/AndroidRuntime(338):  at java.lang.reflect.Field.getDeclaredAnnotations(Native Method) 
ERROR/AndroidRuntime(338):  at java.lang.reflect.Field.getDeclaredAnnotations(Field.java:196) 
ERROR/AndroidRuntime(338):  at java.lang.reflect.AccessibleObject.getAnnotations(AccessibleObject.java:199) 
ERROR/AndroidRuntime(338):  at com.google.gson.FieldAttributes.getAnnotations(FieldAttributes.java:159) 

是否有Gson的注释检查方法?

感谢 克劳斯

+0

从那以后,您是否找到针对此问题的解决方案? – 2014-04-01 09:09:58

+0

@resus不,但我没有追究这个问题,因此无法对目前的状况说些什么。 – FrVaBe 2014-04-01 10:42:28

回答