开发者

Android - How do I find what is causing StringIndexOutOfBoundsException

I have an app that opens up a webview and, in a different thread (asynctask), periodically submits GPS data over http to the server.

I am seeing the following exce开发者_如何学运维ption but having a difficult time pinpointing the source. Can you help? Relative newbie to Android here.

V/  Exception Handler(  206): java.lang.StringIndexOutOfBoundsException
V/  Exception Handler(  206): 
V/  Exception Handler(  206): --------- Stack trace ---------
V/  Exception Handler(  206): 
V/  Exception Handler(  206):     java.lang.String.<init>(String.java:190)
V/  Exception Handler(  206):     android.webkit.FrameLoader.populateStaticHeaders(FrameLoader.java:372)
V/  Exception Handler(  206):     android.webkit.FrameLoader.handleHTTPLoad(FrameLoader.java:222)
V/  Exception Handler(  206):     android.webkit.WebViewWorker.handleMessage(WebViewWorker.java:129)
V/  Exception Handler(  206):     android.os.Handler.dispatchMessage(Handler.java:99)
V/  Exception Handler(  206):     android.os.Looper.loop(Looper.java:130)
V/  Exception Handler(  206):     android.os.HandlerThread.run(HandlerThread.java:60)

The trace gives no indication of what if anything inside my code is causing this. I see only android system code.(or may be I am not looking the right way).


Having a StringIndexOutOfBoundsException in the String constructor is rare enough that I have not encountered it before. What kind of data are you passing to the AsyncTask (which it subsequently passes to WebKit)? Is it a string buffer or some array?

Usually when I can't deduce the cause of a bug, I try:

  • stepping through the code to find out which line causes the crash
  • printing debug statements

EDIT

When I tried to force a StringOutOfBoundsException on my emulator, it was a FATAL EXCEPTION, the log level was Error, and the log tag was AndroidRuntime. In your case, it appears that an ExceptionHandler has caught the exception and has printed the stack trace with the Verbose log level. Is this exception handler your own? or does it belong to the android framework?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜