如何从Android设备获取android应用程序traces.txt文件

时间:2014-02-03 09:47:05

标签: android

我想从Android设备获取我的应用程序traces.txt文件。我检查了谷歌中的很多链接,但仍未获得成功。如果有人有任何想法,请帮助我。 我也查看以下链接。     how to access android files /data/anr/traces.txt and /data/tombstones/tombstones     How to find this stack trace?

我也在尝试这个。     adb -s 0123456789ABCDEF shell#<<<这将为您的设备打开一个shell

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

但我收到此错误“run-as:Package'com.package.name'的安装已损坏。”

4 个答案:

答案 0 :(得分:15)

您可以使用adb执行相同的操作:

adb pull /data/anr/traces.txt

答案 1 :(得分:0)

试试这个。

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

它会将跟踪详细信息存储在SDCArd

有关详细信息,请参阅以下链接

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

答案 2 :(得分:0)

您也可以从非root用户物理设备获取traces.txt。您需要将其复制到SD卡(或设备上的任何可访问位置),然后从那里复制它。打开终端并按照以下步骤操作:

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

希望这有帮助! :)

答案 3 :(得分:0)

这将复制当前设置目录

中anr.txt中的traces.txt
adb shell "cd /data/anr && cat traces.txt" > anr.txt