3

As far as I know, there is currently no JAXB implementation which would work on the Android platform.

I would like to ask a simple question - Is there a need for JAXB on Android?

Being a JAXB enthusiast, I consider writing a JAXB implementation for Android. I probably won't port JAXB RI since it is a bit too fat for the mobile apps, I'd rather write it from scratch. I wrote a JAXB port for JavaScript, so I know this is manageable.

But do you guys need it? Or do are you comfortable with other tools like SimpleXML?

lexicore
  • 42,748
  • 17
  • 132
  • 221

5 Answers5

8

lexicore there is a need for JAXB on android, SimpleXML is great and I prefer it to JAXB in some ways, however JAXB is a standard and is widely used.

A useful example that would be really great is if an Android app could share a jar full of JAXB POJO's with an EE app and use these with RESTful calls to the EE app.

Justin
  • 4,097
  • 1
  • 22
  • 31
  • I repackaged the JAXB RI. Android doesn't support package annotations, so some workaround is needed for this: http://code.google.com/p/android/issues/detail?id=16149 – JasonPlutext May 14 '12 at 08:21
3

As an Android developer who does lot of XML and JSON parsing and framing in almost every app I develop, my answer would be: No, there is no need for JAXB on Android. The other tools fit the bill perfectly. Either that, or we Android developers have got used to the absence of JAXB and each of us have gotten comfortable with one of the alternatives.

In my case, I even achieve code reuse by replacing JAXB with my favorite Android XML serialization library on the server as well.

curioustechizen
  • 10,572
  • 10
  • 61
  • 110
  • 3
    What if you use a library that requires JAXB? Should we rewrite that library too? And keep our fork up to date when the library releases fixes for security bugs? I 've got more useful problems to solve with my programming time. – Geoffrey De Smet Mar 04 '13 at 14:04
2

JAXB appears to almost be a thing on Android. At least, if the contents of this question thread are to be believed.

It seems to be in high demand because the Dalvik VM can't support the components of JAXB that rely on reflection. So, perhaps there is a use for this after all. :)

Community
  • 1
  • 1
MrGomez
  • 23,788
  • 45
  • 72
  • I think that thread states that JAXB is actually _not_ supported on Android, or am I mistaken? – lexicore Mar 23 '12 at 08:18
  • It's not preloaded with Android, but the thread indicates you can slipstream it into your [APK](http://en.wikipedia.org/wiki/APK_(file_format)). Complication: further down, and all over Google, there are a wide and creative variety of complaints that the Dalvik VM can't handle the reflective components. So, on second thought: even if the standard libraries are used in some capacity, at least a _tutorial_ and a canned implementation that works in Android seems to be very much in demand. :) – MrGomez Mar 23 '12 at 08:30
  • See http://www.docx4java.org/blog/2012/05/jaxb-can-be-made-to-run-on-android/ for what you need to do to make the reference implementation run on Android. – JasonPlutext May 18 '12 at 01:50
2

As it turns out, JAXB is not natively supported by Android. An alternative would be to include the library and using it, but that would incur a lot of wasted resources (the JAXB library is pretty big).

In a quick search, IBM Developerworks revealed an interesting article. I skimmed though the document. I don't think the library is as powerful or as versatile as JAXB, but it should fit the bill for most intents and purposes. Moreover, it is natively supported by Android, therefore should be reasonably efficient.

The link to the document is: http://www.ibm.com/developerworks/opensource/library/x-android/

There is another library which comes highly recommended by many. The SF link is: http://sourceforge.net/projects/simple/ The zip package weighs only 2.5M, which means that its pretty light weight.

Leo
  • 37,640
  • 8
  • 75
  • 100
Binaek Sarkar
  • 617
  • 8
  • 21
  • I'm not really looking for JAXB alternatives. My question is, specifically, if JAXB implementation for Andorid is something that people would love to have. – lexicore Mar 25 '12 at 23:30
1

The JAXB reference implementation requires around 3.5MB of space, and uses features that are missing from Android. An Android-compatible implementation will therefore be larger because it will need to supply implementations of those features additionally.

Plenty of Android phones ship with 40MB or less of free space on their internal storage. And that's OEM versions, before networks have "customized" them by adding extra applications and free trials that can't be uninstalled. As long as you want people who have these phones install your application, therefore, you do not want to make it that large. And most app developers want their apps to be as widely usable as possible. It therefore seems to me that the number of people interested in an implementation of a library that large for Android will be very limited.

Jules
  • 14,841
  • 9
  • 83
  • 130
  • My JAXB port for JavaScript was ca. 140kb. Annotations and reflection are definitely an issue, but I think it can be worked around with special XJC plugins. Generally I've just came to a conclusion that the effort just won't be worth it. – lexicore Apr 16 '13 at 21:38