Search code examples
javaandroidxmljackson-dataformat-xml

Android: can/should I use "jackson-dataformat-xml" for XML (un)marshalling?


My Android app will communicates with a SPring Boot REST service using XML.

JAXB is not easy (or light weight) available for Android. So, I read about using jackson-dataformat-xml. I work with Lists of (nested) objects.

My question: is this the preferred way to (un)marshal XML messages? If not, what is a good option for Android? If so, can you help solving the problems below?

JUnit tests pass easily. Compiling is ok using:

packagingOptions {
    pickFirst  'META-INF/license.txt'
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/MANIFEST.MF'
    exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
    exclude 'META-INF/services/com.fasterxml.jackson.core.ObjectCodec'
}

dependencies { 
    .... 
    compile 'com.fasterxml.jackson.core:jackson-core:2.1.2'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.1.2'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.1.2'
    compile( 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.3.0')
}

Running the App is not possible. I get all kinds of errors, like these ones:

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(org.codehaus.stax2.XMLStreamLocation2$1) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.

Edit: In the mean time I see that the Simple XML got good credits.


Solution

  • I am now using Simple XML. That's working fine.