如何解决 FATAL EXCEPTION java.lang.RuntimeException: 执行 doInBackground() 时发生错误
我正在开发与聊天相关的类似应用程序我正在使用后台同步类有时会出现强制关闭我正在使用.net webservices后台我收到消息和图像后台下载过程更新到ui
错误是:
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): FATAL EXCEPTION: AsyncTask #1
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): java.lang.RuntimeException: An error occured while executing doInBackground()
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at android.os.AsyncTask$3.done(AsyncTask.java:200)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.lang.Thread.run(Thread.java:1096)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.ArrayList.get(ArrayList.java:311)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at com.fitzgeraldsoftware.shout.presentationLayer.Shout$LatestMessage.doInBackground(Shout.java:1923)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at android.os.AsyncTask$2.call(AsyncTask.java:185)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): ... 4 more
05-17 05:24:17.956: WARN/ActivityManager(1105): Force finishing activity com.fitzgeraldsoftware.shout.presentationLayer/.Shout
05-17 05:24:18.097: WARN/IInputConnectionWrapper(1618): showStatusIcon on inactive InputConnection
i am developing chat related similar application i am using backgrouund synchronous class some times force close is appear i am using .net webservices back ground i am recieve the messages and images background download process updating to ui
error is:
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): FATAL EXCEPTION: AsyncTask #1
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): java.lang.RuntimeException: An error occured while executing doInBackground()
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at android.os.AsyncTask$3.done(AsyncTask.java:200)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.lang.Thread.run(Thread.java:1096)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.ArrayList.get(ArrayList.java:311)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at com.fitzgeraldsoftware.shout.presentationLayer.Shout$LatestMessage.doInBackground(Shout.java:1923)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at android.os.AsyncTask$2.call(AsyncTask.java:185)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
05-17 05:24:17.925: ERROR/AndroidRuntime(1618): ... 4 more
05-17 05:24:17.956: WARN/ActivityManager(1105): Force finishing activity com.fitzgeraldsoftware.shout.presentationLayer/.Shout
05-17 05:24:18.097: WARN/IInputConnectionWrapper(1618): showStatusIcon on inactive InputConnection
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我面临同样的问题,几乎我花了半天时间,最后解决方案是关闭 eclipse 和 PC/笔记本电脑,重新启动它并运行应用程序。一切都运行良好。
I face the same problem and almost i sepnt half day on it, Finally the solution was Shut down you eclipse and PC/Laptop, Restart it and run the Application. Everything is running fine.
您抛出了
ArrayIndexOutOfBoundsException
。检查Shout.java
中 1923 年执行的代码以进行数组访问。如果您尝试按索引读取大于数组大小(1)的元素,则会引发异常。例如,如果出现以下情况,则会抛出该异常:You have
ArrayIndexOutOfBoundsException
thrown. Check the code executed on 1923 inShout.java
for array access. The exception is thrown if you try to read element by index which is more than array size(1). For example it is thrown if:尝试
项目 ->清理
然后运行......我已经这样解决了......Try
Project -> Clean
and then Run.... I have Solved it this way.......