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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21523999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:42:19  来源:igfitidea点击:

How to get android application traces.txt file from android device

android

提问by jiten

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/tombstonesHow to find this stack trace?

我想从 android 设备获取我的应用程序 traces.txt 文件。我在谷歌上检查了很多链接,但仍然没有成功。如果有人有任何想法,请帮助我。我还检查了下面的链接。 如何访问 android 文件 /data/anr/traces.txt 和 /data/tombstones/tombstones如何找到这个堆栈跟踪?

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

我也在尝试这个。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

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

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

但我收到此错误“运行方式:包 'com.package.name' 安装已损坏。”

回答by Arpana

You can do the same thing using adb:

你可以使用 adb 做同样的事情:

adb pull /data/anr/traces.txt

回答by Sniper

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

它将跟踪详细信息存储在 SDCard 中

for more details see the below link

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

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

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

回答by codemonger

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:

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

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

Hope this helps! :)

希望这可以帮助!:)

回答by Rachita Nanda

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

这将复制您当前设置目录中 anr.txt 中的 traces.txt

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