title: Using jackson-dataformat-xml on android
body: <p>I'm strugling with using jackson-dataformat-xml on android</p>
  
  <p>I have some very basic code that works fine on oracle jre</p>
  
  <pre><code>JacksonXmlModule module = new JacksonXmlModule();
  module.setDefaultUseWrapper(false);
  XmlMapper xmlMapper = new XmlMapper(module);
  </code></pre>
  
  <p><strong>First I tried <a href="https://github.com/FasterXML/jackson-dataformat-xml" rel="noreferrer">official documentation</a> adapted for gradle</strong> (by me, not sure if done correctly):</p>
  
  <pre><code>compile 'com.fasterxml.jackson.core:jackson-core:2.5.4'
  compile 'com.fasterxml.jackson.core:jackson-annotations:2.5.4'
  compile 'com.fasterxml.jackson.core:jackson-databind:2.5.4'
  compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.5.4'
  
  compile 'org.codehaus.woodstox:woodstox-core-asl:4.4.1'
  compile 'javax.xml.stream:stax-api:1.0-2'
  </code></pre>
  
  <p>Result: gradle fails build time about bundling corelibraries into an application</p>
  
  <pre><code>...
  :app:preDexDebug
  trouble processing "javax/xml/stream/EventFilter.class":
  Ill-advised or mistaken usage of a core class (java.* or javax.*)
  when not building a core library.
  ...
  </code></pre>
  
  <p><strong>2nd attempt trying to follow Sean's <a href="https://stackoverflow.com/questions/5461127/using-jaxb-with-google-android">answer</a></strong>
  (Basicly he repackages corelibs with prefix names and rebuilds jackson-dataformat-xml to use the prefixed names)</p>
  
  <pre><code>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'
  // Repackaged XML-specific libraries
  compile 'edu.usf.cutr.android.xml:jackson-dataformat-xml-android:2.1.2'
  compile 'edu.usf.cutr.android.xml:stax2-api-android:3.1.1'
  compile 'edu.usf.cutr.android.xml:stax-api-android:1.0-2'
  compile 'edu.usf.cutr.android.xml:aalto-xml-android:0.9.8'
  </code></pre>
  
  <p>And build time failed on duplicates </p>
  
  <pre><code>Duplicate files copied in APK META-INF/services/com.fasterxml.jackson.core.ObjectCodec
  </code></pre>
  
  <p>so added:</p>
  
  <pre><code>packagingOptions {
      ...
      exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
      exclude 'META-INF/services/com.fasterxml.jackson.core.ObjectCodec'
  }
  </code></pre>
  
  <p>When adding the exclusions it builds and deploys, but fails runtime on below stackdump (AFAIK it cant find the SAX provider, even tho it is added to the classpath to my understanding)</p>
  
  <pre><code>edu.usf.cutr.javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.MXParserFactory not found
              at edu.usf.cutr.javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
              at edu.usf.cutr.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
              at edu.usf.cutr.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
              at edu.usf.cutr.javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
              at com.fasterxml.jackson.dataformat.xml.XmlFactory.&lt;init&gt;(XmlFactory.java:97)
              at com.fasterxml.jackson.dataformat.xml.XmlFactory.&lt;init&gt;(XmlFactory.java:85)
              at com.fasterxml.jackson.dataformat.xml.XmlFactory.&lt;init&gt;(XmlFactory.java:82)
              at com.fasterxml.jackson.dataformat.xml.XmlMapper.&lt;init&gt;(XmlMapper.java:46)
  </code></pre>
  
  <p>What is the proper way to move forward on either #1 or #2?</p>