编程语言
首页 > 编程语言> > android – 如何解决FATAL EXCEPTION java.lang.RuntimeException:执行doInBackground()时发生错误

android – 如何解决FATAL EXCEPTION java.lang.RuntimeException:执行doInBackground()时发生错误

作者:互联网

我正在开发聊天相关类似的应用程序我正在使用backgrouund同步类有时强制关闭出现我正在使用.net webservices back ground我收到消息和图像后台下载过程更新到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

解决方法:

您抛出了ArrayIndexOutOfBoundsException.检查Shout.java中1923年执行的代码以获取数组访问权限.如果您尝试按索引读取超过数组大小(1)的元素,则抛出异常.例如,如果出现以下情况则抛出:

String [] strings = new String[0];
strings[0];// exception thrown!

标签:fatal-error,android,synchronization
来源: https://codeday.me/bug/20190903/1797223.html