How To Use Javax.xml.transform.stax In Android Studio?
Solution 1:
Android doesn't use the same Java JDK as what you use for a desktop or server app; it uses its own implementation of the JDK, which adds the android.*
hierarchy but leaves out some packages that are in the standard JDK, especially in the javax.*
Java extensions. Unfortunately for you, javax.xml.stream
and javax.xml.transform.stax
are among the things they didn't choose to implement. Moreover, the Android runtime won't allow you to load any java.*
or javax.*
classes from an external JAR file for security reasons**. This answer may describe the situation a little better.
Your best bets are probably: 1) use a different third-party library specifically built for Android, such as SimpleXML; 2) look for a repackaged version of the libraries, like this JAXB effort; or 3) use a tool like Jar Jar Links to do the repackaging for you.
Also see this excellent guide on parsing JSON and XML in Android.
** Note: I can't find any documentation from Google to substantiate this; it's just a commonly repeated "fact". If anyone can point to an authoritative statement about Android's handling of third-party java[x].*
classes, please comment with a link, or edit this answer.
Post a Comment for "How To Use Javax.xml.transform.stax In Android Studio?"