1

I am trying to create an instance of XMLGregorianCalendar in android code

XMLGregorianCalendar startDate = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar();

I am running into this error:

Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl" on path: DexPathList[[zip file "/data/app/com.comp.appname-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

I have tried adding xerces for android jar but it is returning

mf.javax.xml.datatype.XMLGregorianCalendar

where as I have to create of type javax.xml.datatype.XMLGregorianCalendar. Can someone please guide me how to create XMLGregorianCalendar instance?

Mi-Creativity
  • 9,554
  • 10
  • 38
  • 47
venkata
  • 51
  • 4
  • did you have `org.apache.xerces` in your classpath? – Deividi Cavarzan Dec 20 '15 at 03:09
  • I mean, in build.gradle? Why dont you use normal `Date` object or Joda-Time? – Deividi Cavarzan Dec 20 '15 at 03:17
  • i am an external api in my code and that expects XMLGregorianCalendar for a date, so cant use other date types. If i download and include xercesImpl, running in to the following exception :: Caused by: java.lang.IllegalArgumentException: bad utf-8 byte a0 at offset 00000004 – venkata Dec 20 '15 at 03:30
  • i have a eclipse based android project, let me know if you want me to check any thing. Also note that the exception is coming when i am running my android app – venkata Dec 20 '15 at 03:32
  • are you using gradle or maven? – Deividi Cavarzan Dec 20 '15 at 03:33
  • it is a android proj created using eclipse. It is neither Maven nor gradle. i believe it internally uses ant (not sure though, my guess) – venkata Dec 20 '15 at 03:41
  • So, the second error is not related anymore, seems to be some issue with utf8 – Deividi Cavarzan Dec 20 '15 at 03:44
  • yep. as i mentioned above if i copy xerces jar to my libs folder, try to build project, it throws that utf-8 and does not build apk any more .. some more console log info [2015-12-19 22:29:25 - CX3] Dx 1 error; aborting [2015-12-19 22:29:25 - CX3] Conversion to Dalvik format failed with error 1 – venkata Dec 20 '15 at 03:48
  • Probably This jar could be executed in Android environment – Deividi Cavarzan Dec 20 '15 at 03:50
  • followed similar threads, but was of no help.. i am open to try different things ... http://stackoverflow.com/questions/7918466/cant-use-xmlgregoriancalendar-in-android-even-if-it-is-documented – venkata Dec 20 '15 at 03:53
  • @venkata did u able to fix this problem.? I am facing the same issue...can you suggest me anything? – Neha Sep 07 '16 at 09:44
  • has anyone found a solution to this ??? – Sagar Nayak Aug 25 '17 at 10:56

0 Answers0