简体   繁体   English

如何在不连接 PC 的情况下在设备中保存 android 运行时错误日志?

[英]How to save android runtime error logs in device without connected to PC?

I just wanna to ask if it is possible to save android runtime error information in sdcard without device connected to PC?我只是想问一下是否可以在没有设备连接到PC的情况下将android运行时错误信息保存在sdcard中? I tried to run:我试着跑:
adb shell "logcat -v threadtime *:V > /mnt/sdcard/logcat_log.txt"

which is lack of runtime error when I plug out the USB.这是当我拔出 USB 时没有运行时错误。

Any thoughts?有什么想法吗? Thanks for your comments.感谢您的意见。


Here some information I just digged.这是我刚刚挖掘的一些信息。 From the very beginning, I though this command 'adb shell "logcat -v threadtime -f /mnt/sdcard/logcat_log.txt"' will output logs into the file 'logcat_log.txt' continuelly.从一开始,我虽然这个命令 'adb shell "logcat -v threadtime -f /mnt/sdcard/logcat_log.txt"' 将继续将日志输出到文件 'logcat_log.txt' 中。 After several times of testing, checking and document reading about logcat, I have found that this command will only flush log buffers of android and then STOP .经过多次测试、检查和阅读有关 logcat 的文档,我发现此命令只会刷新 android 的日志缓冲区,然后STOP That's why I can not get the runtime error info in this file without flush the log buffer again.这就是为什么我无法在不再次刷新日志缓冲区的情况下获取此文件中的运行时错误信息的原因。 Thanks Pragna and Narkha for your replys.感谢 Pragna 和 Narkha 的回复。


I just put my solution here to whom in the future may needs it.我只是把我的解决方案放在这里给将来可能需要它的人。 My testing platform is windows 7, it would be better if you were using Linux or Mac OS X, and solution contains bat script for windows, shell scripts for android shell;我的测试平台是windows 7,如果你使用Linux或Mac OS X会更好,解决方案包含windows的bat脚本,android shell的shell脚本; they are run.bat, logcat.sh, run_monkey.sh and run_logcat.sh.它们是 run.bat、logcat.sh、run_monkey.sh 和 run_logcat.sh。

#"run.bat"
adb shell "echo "" > /mnt/sdcard/logcat_log.txt"  #clean up previous log
adb push logcat.sh /mnt/sdcard/            #
start bash run_logcat.sh
start bash run_monkey.sh
pause

#"logcat.sh"
logcat -v threadtime *:V > /mnt/sdcard/logcat_log.txt

#"run_monkey.sh"
adb shell "monkey -p com.test.androidclient --throttle 300 -c android.intent.category.MONKEY -c android.intent.category.LAUNCHER -c android.intent.category.DEFAULT --pct-majornav 20 --monitor-native-crashes --ignore-security-exceptions --ignore-crashes --ignore-timeouts --kill-process-after-error -s 220 -v -v -v 99999" 

#"run_logcat.sh"
adb shell "sh /mnt/sdcard/logcat.sh &"
try {
    File logfile= new File(Environment.getExternalStorageDirectory()+"/logfile.log"); 
    filename.createNewFile(); 
    String cmd = "logcat -d -f "+logfile.getAbsolutePath();
    Runtime.getRuntime().exec(cmd);
} catch (IOException e) {

    e.printStackTrace();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Android设备中将运行时错误日志保存在何处以及如何保存? - Where and how runtime error logs are saved in Android device? 检测到连接到PC的Android设备 - Detected android device connected to PC 如何检测连接到我的PC的ADB设备 - How to detect ADB device connected to my PC 如何制作一个Android应用程序,从我的Android设备连接在同一个wifi上的电脑的IP地址 - How to make an android app to get the IP address of the pc from my android device connected on same wifi 如何在不使用DDMS的情况下将Android设备屏幕的图像捕获到PC? - how to capture an image of android device screen to PC without using DDMS…? 如何从没有客户端服务器的Android设备控制PC鼠标 - how to control pc mouse from android device without client server 如何在通过WiFi连接的Android设备上查看从PC的c ++代码生成的openGL渲染? - How to view an openGL renders generated from PC's c++ code on an Android Device connected via WiFi? 我们如何从 PC 的浏览器(都连接到同一网络)向 android 设备发送消息 - How can we send message to the android device from a browser of PC (both connected with same network) 如何找到通过USB连接到android设备的台式机的IP地址 - How to find IP address of desktop pc which is connected to android device through USB android - 如何在没有密码的情况下检查设备是否已连接到wifi? - android - how to check if device has connected to wifi without password?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM