Jackson library JaxbAnnotation throwing exception on Android

39 views
Skip to first unread message

Lakshmi Narayana Malempati

unread,
Nov 30, 2021, 6:19:27 AM11/30/21
to jackson-user
Trying to use a java jar file on Android which uses Jackson lib. But getting the below errors, stack trace attached.
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/bind/annotation/XmlElement;
Background:
We have a  java archive file, which uses jackson library - JAXB Annotations for serializing to xml.We are trying call the functionality from Android app.  The same worked fine on windows.


We are using the below gradle dependencies:
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.1.1'
implementation 'javax.xml.stream:stax-api:1.0-2'
implementation 'com.fasterxml:aalto-xml:1.0.0'
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-jaxb-annotations', version: '2.13.0'

Could someone please let me know what I am missing here. Does jackson works for Android to begin with?

Thanks.


Android-Jackson-jaxb-annotations-error.txt

Tatu Saloranta

unread,
Nov 30, 2021, 3:09:12 PM11/30/21
to jackson-user
On Tue, Nov 30, 2021 at 3:19 AM Lakshmi Narayana Malempati <lmale...@gmail.com> wrote:
Trying to use a java jar file on Android which uses Jackson lib. But getting the below errors, stack trace attached.
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/bind/annotation/XmlElement;
Background:
We have a  java archive file, which uses jackson library - JAXB Annotations for serializing to xml.We are trying call the functionality from Android app.  The same worked fine on windows.


We are using the below gradle dependencies:
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.1.1'

This is a very, very old version from 2012; it should be upgraded for one, but...
 
implementation 'javax.xml.stream:stax-api:1.0-2'
implementation 'com.fasterxml:aalto-xml:1.0.0'
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-jaxb-annotations', version: '2.13.0'

This would not work with XML module 2.1.x -- typically Jackson component versions should really have the same minor version (sometimes "close enough" ones may happen to work tho).

However: for the longest time, Android platform neither included nor allowed JAXB api classes (java.xml.bind) or Stax (javax.xml.stream).
I don't know if this limitation was lifted at some point, and if so at what version.
 

Could someone please let me know what I am missing here. Does jackson works for Android to begin with?

Jackson core components do work, but Javax extensions (like JAXB, Stax API) have been problematic on Android.

So I am not 100% sure if XML module works, and on which Android SDK levels. I hope Android developers can share
their experiences.

-+ Tatu +-
 

Thanks.


--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/466f39b2-3061-49d4-9ff5-ba613974bc28n%40googlegroups.com.

Lakshmi Narayana Malempati

unread,
Dec 2, 2021, 10:55:00 AM12/2/21
to jackson-user
Thank you for the help.

On android, when I have tried with  implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.0', the latest version, getting no class found errors. Then I have tried randomly - see that 2.9.0 also worked but not later. 

Also, any android developers, please share your experience working with Jackson.
Reply all
Reply to author
Forward
0 new messages