7

I want to get the my application traces.txt file from the android device. I check lots of the link in the google, but still not get success. If any one have any idea, please help me. I also check the below link. how to access android files /data/anr/traces.txt and /data/tombstones/tombstones How to find this stack trace?

I am also trying this. adb -s 0123456789ABCDEF shell # <<< This will open a shell to your device

ps | grep com.package.name # This will list some info about the running         instance of your app
# Output should be something like: 
# u0_a7    18941 173   869348 26040 ffffffff 00000000 S    com.package.name
# Important is the PID (number in the second column), in this case 18941.

# Now send the SIGQUIT to your process, please change '18941' to your PID
run-as com.package.name kill -3 18941

# Now Android should have created the file /data/anr/traces.txt, check that:
ls -l /data/anr/traces.txt 
# Output should be something like
# -rw-rw-rw- system   system     325391 2014-02-03 14:11 traces.txt

# And finally pull that file
exit

adb -s 0123456789ABCDEF pull /data/anr/traces.txt

but I am getting the this error "run-as: Package 'com.package.name' has corrupt installation."

Community
  • 1
  • 1
jiten
  • 180
  • 1
  • 2
  • 12

4 Answers4

15

You can do the same thing using adb:

adb pull /data/anr/traces.txt
Rob
  • 4,927
  • 12
  • 49
  • 54
Arpana
  • 342
  • 1
  • 3
  • 13
  • but how to add package name with this commands?. – jiten Feb 03 '14 at 10:26
  • connect ur device with PC and run command, this traces file will copied on to the platform-tools directory – Arpana Feb 03 '14 at 10:30
  • Its default path of traces.txt file for all the Application – Arpana Feb 03 '14 at 10:31
  • 2
    but its showing this "failed to copy '/data/anr/traces.txt' to './traces.txt': Permission denied". – jiten Feb 03 '14 at 11:26
  • 1
    just try this adb shell ---> cd data/anr and than cat traces.txt – Arpana Feb 03 '14 at 11:37
  • by doing this you can also read file. – Arpana Feb 03 '14 at 11:38
  • please check this, $ adb shell shell@android:/ $ cd data cd data shell@android:/data $ cd anr cd anr shell@android:/data/anr $ cat traces.txt cat traces.txt /system/bin/sh: cat: traces.txt: Permission denied 1|shell@android:/data/anr $ – jiten Feb 03 '14 at 11:43
  • Run this command ls -l traces.txt inside data.anr and check what are the permission you have for traces.txt – Arpana Feb 03 '14 at 11:46
  • 127|shell@android:/data/anr $ ls -l traces.txt ls -l traces.txt -rw------- system system 0 2014-02-03 12:07 traces.txt shell@android:/data/anr $ – jiten Feb 03 '14 at 11:50
  • above commands shows the rw permission. – jiten Feb 03 '14 at 11:51
  • what best you can do just unplug and plug again your device with PC and try ;) – Arpana Feb 03 '14 at 11:55
  • or just delete this file by using rm -r traces.txt and regenerate file once again – Arpana Feb 03 '14 at 11:55
  • again permission denied,"$ adb shell shell@android:/ $ cd data cd data shell@android:/data $ cd anr cd anr shell@android:/data/anr $ rm -r traces.txt rm -r traces.txt rm failed for traces.txt, Permission denied " – jiten Feb 03 '14 at 12:05
  • sorry for downvote, I did it by mistake. will cancel it after answer will be edited. It is very useful answer for me – hov.terteryan Dec 28 '17 at 12:08
  • I removed traces.txt file and I was thinking that it will be generated again but it did not. How would I achieve that file again? – Hilal Dec 11 '19 at 16:57
0

Try this.

// start tracing to "/sdcard/calc.trace"
Debug.startMethodTracing("Name of yours");
// ...
// stop tracing
Debug.stopMethodTracing();

it will store the trace details in the SDCArd

for more details see the below link

http://developer.android.com/guide/developing/debugging/debugging-tracing.html

Sniper
  • 2,412
  • 11
  • 44
  • 49
0

You can get traces.txt from non-rooted physical devices as well. You need to copy it on sdcard (or any accessible location on your device), and then copy it from there. Open your terminal and follow these steps:

./adb shell
cat /data/anr/traces.txt.bugreport  > /sdcard/traces.txt
./adb pull /sdcard/traces.txt

Hope this helps! :)

codemonger
  • 47
  • 8
0

This will copy traces.txt in anr.txt in your current set directory

adb shell "cd /data/anr && cat traces.txt" > anr.txt
Rachita Nanda
  • 4,509
  • 9
  • 42
  • 66