Android StAX Cursor Parser - could not find method javax.xml.stream.XMLInputFactory.newInstance

冷暖自知 提交于 2019-12-10 11:16:11

问题


I'm using AsyncTask to download and parse XML content from i-net. Downloading and parsing of the xml happens in doInBackground() method. The "dalvikvm" encounters a problem - it could not find a method.

Here is the log of LogCat:

06-30 13:26:41.148: DEBUG/dalvikvm(507): GC freed 796 objects / 68088 bytes in 112ms

06-30 13:26:41.667: INFO/ActivityManager(52): Displayed activity com.news.reader/.SplashScreen: 5305 ms (total 63417 ms)

06-30 13:26:45.097: INFO/ActivityManager(52): Starting activity: Intent { cmp=com.news.reader/.DirBgNewsReader }

06-30 13:26:45.418: ERROR/dalvikvm(507): Could not find method javax.xml.stream.XMLInputFactory.newInstance, referenced from method com.news.reader.DirBgNewsReader.parse

06-30 13:26:45.427: WARN/dalvikvm(507): VFY: unable to resolve static method 104: Ljavax/xml/stream/XMLInputFactory;.newInstance ()Ljavax/xml/stream/XMLInputFactory;

06-30 13:26:45.427: WARN/dalvikvm(507): VFY:  rejecting opcode 0x71 at 0x0013

06-30 13:26:45.427: WARN/dalvikvm(507): VFY:  rejected Lcom/news/reader/DirBgNewsReader;.parse (Ljava/lang/String;)V

06-30 13:26:45.427: WARN/dalvikvm(507): Verifier rejected class Lcom/news/reader/DirBgNewsReader;

06-30 13:26:45.439: WARN/dalvikvm(507): Class init failed in newInstance call (Lcom/news/reader/DirBgNewsReader;)

06-30 13:26:55.217: WARN/ActivityManager(52): Launch timeout has expired, giving up wake lock!

06-30 13:26:55.217: WARN/ActivityManager(52): Activity idle timeout for HistoryRecord{4396eb68 com.news.reader/.DirBgNewsReader}

06-30 13:27:00.300: WARN/ActivityManager(52): Activity destroy timeout for HistoryRecord{43814048 com.news.reader/.SplashScreen}

Could some one to help me and explain why it couldn't find the specified method?

Thanks!


回答1:


Looking on Google, I found this and this.

Looks like StAX is not available on Android, but that an "equivalent" XmlPullParser is available.




回答2:


I found Blog Post simple-xml-in-android-1-5-and-up (the answer by dleerob and Triminmon) helpful because it explains what Simple XML is doing:

Now these are some odd errors ... in a nutshell, right here is where Simple XML works some reflection magic to see what classes it can actually use to serialize your XML. Simple XML was made to work essentially anywhere (which is why it works on Android 1.5) and this reflection code tells it what its current platform gives it to work with. It also caches the result of this reflection so you will only see these error messages appear once and then Simple XML has automatically ‘reconfigured’ itself, if you like.




回答3:


This blog post explains exactly what is going on with those errors, and that they can safely be ignored.

Blog Post



来源:https://stackoverflow.com/questions/6545052/android-stax-cursor-parser-could-not-find-method-javax-xml-stream-xmlinputfact

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!