如何找到这个堆栈跟踪?

发布于 2024-12-23 15:13:08 字数 226 浏览 2 评论 0原文

我的程序一直崩溃,但是logcat没有显示任何异常。我刚刚收到以下消息,以及大量有关 CPU 使用情况的统计信息。显然我使用了太多的 CPU,但我不知道我的程序的哪一部分正在执行此操作。下面的文件在哪里?我找不到它。

12-30 23:13:06.639: INFO/dalvikvm(7688): 将堆栈跟踪写入 '/data/anr/traces.txt'

My program keeps crashing, but the logcat does not show any exceptions. I just get the following message, plus a lot of stats about CPU usage. Clearly I'm using too much of the CPU, but I don't know what part of my program is doing this. Where is the following file? I can't find it.

12-30 23:13:06.639: INFO/dalvikvm(7688): Wrote stack trace to
'/data/anr/traces.txt'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

药祭#氼 2024-12-30 15:13:08
adb shell

-->

cat /data/anr/traces.txt

编辑:

您需要具有 root 访问权限才能修改 /data/ 中的文件,您应该能够使用 https://market.android.com/details?id=com.estrongs.android.pop

一旦您拥有该应用程序,请打开它 -->菜单-->设置-->主目录(从 /sdcard/ 更改为 /) -->退出应用程序 -->再次打开它

然后您应该能够浏览到 /data/anr/*

EDIT2(附加信息,基于评论),以便在实际测试后与已发布的应用程序一起使用:

  • 大多数开发人员依赖 开发者控制台错误报告,用于在用户访问时查看堆栈跟踪和错误日志提交错误报告。

  • 其他人实现自己的库或使用ACRA

请注意,某些用户不会仅仅因为某个应用使用了读取敏感日志数据的权限。

adb shell

-->

cat /data/anr/traces.txt

EDIT:

You need to have root access to modify the files in /data/ you should be able to access the file with an app like https://market.android.com/details?id=com.estrongs.android.pop

Once you have that app, open it --> Menu --> Settings --> Home Directory (Change from /sdcard/ to /) --> Exit the app --> Open it again

Then you should be able to browse to /data/anr/*

EDIT2 (Additional info, based on comments) for use with a published app after hands on testing:

  • Most developers rely on the developer console error reporting to see the stacktrace and error logs when a user submits an error report.

  • Others impliment their own or use a library like ACRA

Be warned some users do not install an app simply because it uses the permission to read sensitive log data.

真心难拥有 2024-12-30 15:13:08

为了在不剪切文件头的情况下舒适地查看,请使用以下一行命令:

adb shell“cat /data/anr/traces.txt”|少

For comfortable viewing without cutted head of file use following one-line command:

adb shell "cat /data/anr/traces.txt" | less

挽袖吟 2024-12-30 15:13:08

ANR 代表“Android 无响应”,它并不意味着您使用了太多的 CPU,而是意味着 UI 主循环程序在给定的时间内没有被调用。 UI 循环程序负责处理用户输入,因此从用户的角度来看,应用程序对输入没有响应。通常,这是由于在主 UI 线程上执行长时间运行或阻塞操作而导致的。例如,在主线程上下载文件可能会导致 ANR。通常,仅从该信息中就可以很容易地找出导致 ANR 的代码。

The ANR stands for "Android Not Responding" and it doesn't mean you're using too much of the CPU, it means that the UI main looper hadn't been called for a given amount of time. The UI looper takes care of user input, so from the point of view of your user, the app was unresponsive to input. Usually this is caused by doing long-running or blocking operations on the main UI thread. For example, downloading a file on the main thread could cause an ANR. Usually it's pretty easy to pick out the code that causes an ANR just from that information.

不…忘初心 2024-12-30 15:13:08

如果您在 Windows 上使用 Android Studio,则可以执行以下操作:

在 Andriod Studio 中:

View > Tool Windows > Device File Explorer

这应该会打开一个新窗口,其中包含设备上的所有文件(堆栈跟踪的位置)位于),然后您可以导航到“/data/anr/traces.txt”,只需双击该文件即可将其打开。

If you are on Windows with Android Studio, you can do the following:

In Andriod Studio:

View > Tool Windows > Device File Explorer

This should open a new window with all files on the device (where your stack trace is located), then you can navigate to '/data/anr/traces.txt', just double click on the file will open it up for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文