15

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'

4 Answers4

18
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.

TryTryAgain
  • 7,632
  • 11
  • 46
  • 82
  • I'm using Eclipse in WIndows. I can look in the files on my device/emulator but traces.txt doesn't seem to be anywhere. –  Dec 30 '11 at 14:39
  • Updated my answer. You can use an app to access that file. – TryTryAgain Dec 30 '11 at 15:17
  • How can you access this file without root access (such as stock HTC phones)? – Amplify91 Apr 05 '12 at 23:04
  • What do you mean by "access"? Read, copy, write? – TryTryAgain Apr 06 '12 at 00:00
  • You wouldn't access the trace file from other user's phones, rather you would be sending off the logcat to a server so you can analyze it: http://stackoverflow.com/questions/983761/android-java-simple-send-and-recieve-with-server-fast-setup-challenge I'll update my answer with some possible uses. – TryTryAgain Apr 06 '12 at 00:27
  • 2
    You shouldn't have to root. I think doing 'adb pull /data/anr/traces.txt ~/Desktop' should work just fine. – dnkoutso Sep 24 '12 at 17:08
9

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

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

ruX
  • 7,224
  • 3
  • 39
  • 33
4

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.

Samuel
  • 16,923
  • 6
  • 62
  • 75
0

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.

happyhardik
  • 24,987
  • 7
  • 47
  • 60