Using JAXB with Google Android(将 JAXB 与 Google Android 一起使用)
问题描述
我需要解析通过 xml 传递的 java 对象.我想将 JAXB 框架用于这些目的,因为我已经预先注释(使用 JAXB)java 类.
I need to parse the java-objects which are passed through xml. I want to use for these purposes JAXB framework, because I have pre-annotated (using JAXB) java-class.
这原则上可行吗?
InputStream input = entity.getContent();
JAXBContext jc = JAXBContext.newInstance(new Class[] {Response.LoginResponse.class});
Unmarshaller un = jc.createUnmarshaller();
LoginResponse response = (LoginResponse)un.unmarshal(input);
在第 4 行,我有一个警告:无法解析静态方法 282 JAXBContext ..."然后虚拟机崩溃
in line 4, I have a warning: "unable to resolve static method 282 JAXBContext ... " and then VM crashes
关于如何解决这个问题的任何想法?
Any ideas on how to solve this problem?
推荐答案
我并没有完全解决您的问题,但 JAXB 默认不包含在 android 中,该库将花费您 9(!) MB 的 apk.改用 SimpleXML.它具有类似的能力,而且更轻量级.
I'm not exactly resolving your problem, but JAXB isn't included in android by default and the library will cost you 9(!) MB of your apk. Try SimpleXML instead. It has similiar abilities and much more lightweight.
这篇关于将 JAXB 与 Google Android 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 JAXB 与 Google Android 一起使用


基础教程推荐
- LocationClient 与 LocationManager 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01