4

I am developing an application and it keeps crashes randomly. I finally catch the logcat when it crashes.

here are the lines I got

01-30 01:04:47.281    2856-2856/com.snappext:hascode_process I/System.out﹕ Done
01-30 01:05:02.617    2856-2861/com.snappext:hascode_process I/dalvikvm﹕ threadid=3: reacting to signal 3
01-30 01:05:02.640    2856-2861/com.snappext:hascode_process I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt'
01-30 01:05:39.304    2750-2752/com.snappext D/dalvikvm﹕ GC_CONCURRENT freed 830K, 14% free 11618K/13383K, paused 1ms+3ms

now I need to know how to read '/data/anr/traces.txt' I am using my Samsung S2 for testing

Rehab Saad
  • 53
  • 1
  • 5
  • possible duplicate of [How can I read a text file in Android?](http://stackoverflow.com/questions/12421814/how-can-i-read-a-text-file-in-android) – JunYoung Gwak Jan 30 '15 at 00:02

3 Answers3

10

you can use this cmd

adb pull /data/anr/traces.txt

you will need to navigate to adb folder under android installation

John Donvan
  • 544
  • 6
  • 21
4

You might try to do a adb shell "ls /data/anr" which will list all the the trace files in that directory. Atleast on my device I don't have permission to list the /data folder but I do for /data/anr

On my LG G3, despite the message saying it wrote to /data/anr/traces.txt it would in fact keep several. Could be Xamarin/Mono I'm developing with doing this but the file I needed was actually /data/anr/traces_<PKG_NAME>.txt where <PKG_NAME> is the Android Package of the App but with each . replaced with a _ (ex: com.my.project -> com_my_project).

It also kept other trace files, presumably for non-debugging apps, with the pattern traces00.txt, traces01.txt, ... traces10.txt. In short there wasn't a 'normal' traces.txt file in that folder, but many starting with 'traces' and ending in '.txt'

Russ
  • 1,706
  • 12
  • 17
3

If you're using Windows:

  1. Open cmd / terminal
  2. cd to SDK folder (see: Find SDK location from Android Studio)

    • Windows: cd c:/android-sdk
    • OSX: cd /Users/<user>/Library/Android/sdk
  3. cd platform-tools

  4. adb pull /data/anr/traces.txt
  5. Check c:/android-sdk/platform-tools/traces.txt

On step 4 you can get some errors:

Community
  • 1
  • 1
RominaV
  • 3,085
  • 1
  • 26
  • 52