帮助读取 Android 中的 ANR 堆栈跟踪
一段时间以来,我一直在与我的一项服务中发生的 ANR 作斗争。重现起来非常困难,而且 UI 似乎在 100% 发生之前就具有完整的功能,从来没有任何明显的滞后或冻结。我的服务有一个 TimerTask 和一些运行的 AsyncTask,仅此而已。
当您在 2.2 中向 Android Market 报告它时,我得到的堆栈跟踪很难阅读,似乎没有直接引用我的任何代码,而仅引用了 SDK 中的类。任何人都可以看一下堆栈跟踪,看看您是否可以知道发生了什么。
打印输出太大,我选择将其发布到 Pastebin,我希望这不违反规则。 http://pastebin.com/KHUD0UHW
这也是 Logcat 日志 http://pastebin.com/V5xSey36
I have been battling an ANR happening in one of my services for a while now. It is very hard to reproduce and the UI seems to have full functionality right before it happens 100% of the time there is never any noticeable lag or freezing. My service has a TimerTask and a few AsyncTask's that it runs and that is it.
The stack traces I get when you report it with the Android Market in 2.2 are hard to read, there doesn't seem to be a reference to any of my code directly but only from classes in the SDK. Can anyone take a look at the stacktrace and see if you can tell what is going on.
The print out is so large I opted to post it to pastebin, I hope that isn't against the rules.
http://pastebin.com/KHUD0UHW
Here is the Logcat log as well
http://pastebin.com/V5xSey36
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能不是您的应用程序的错误。无论“当前”应用程序是什么,都会显示 ANR。但是,如果系统上的另一个应用程序确实占用了您的 CPU 并迫使您的应用程序挨饿,则您的应用程序将收到 ANR,因为它占据了用户的焦点。如果是这种情况,你就无能为力了。也许测试这一点的最佳方法是观察或强制系统进行同步。同步通常对手机来说非常繁重,并且可能会在功能较弱的手机上导致严重的延迟。
测试您的手机是否速度较慢的另一种方法是安装市场上的大型应用程序。下载后进入“安装”阶段后,请在应用程序中执行一些密集操作。如果安装阶段花费的时间超过 5 秒左右,则很有可能让您的应用获得 ANR。这是因为安装应用程序时 IO 速度不佳。 IO 阻止其他应用程序获取 CPU 时间。 Android 认为这意味着您正在窃取它。
It's possible that it's not your apps fault. An ANR shows up for whatever the 'current' app is. However if another app on the system was really taking out your CPU and forcing your app to starve, your app will get the ANR because it has the user's focus. If that is the situation, there is nothing you can do. Perhaps the best way to test for this is watch for or force the system to do a sync. Syncs are usually quite heavy on the phone and can cause bad lag on less powerful phones.
Another way to test if you have a slower phone is to install a big app from the market. Once it goes in to the 'Installing' phase after downloading, do something just a little bit intensive in your app. If the installing phase takes longer than 5 seconds or so, it has quite a decent chance to make your app get the ANR. This is because of bad IO speeds while installing the app. IO blocks other apps from getting CPU time. Android thinks that means that you are stealing it.