如何保存的Andr​​oid运行时错误日志中的设备,而无需连接到电脑? [英] How to save android runtime error logs in device without connected to PC?

查看:281
本文介绍了如何保存的Andr​​oid运行时错误日志中的设备,而无需连接到电脑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想问,如果有可能节省SD卡的Andr​​oid运行时错误信息,而无需连接到PC设备?我试图运行:结果
ADB壳的logcat -v threadtime *:V> /mnt/sdcard/logcat_log.txt

这是缺乏运行时错误,当我拔掉USB。

有什么想法?感谢您的意见。


下面的一些信息,我只是挖。从一开始,我以为这个命令'亚行壳的logcat -v threadtime -f /mnt/sdcard/logcat_log.txt'将输出到日志文件'logcat_log.txtcontinuelly。经过测试,检查和文件阅读logcat的几次,我发现,这条命令将Android和然后点击 STOP仅刷新日志缓冲区。这就是为什么我不能再得到此文件中的运行时错误信息没有刷新日志缓冲区。感谢Pragna和Narkha你的回信。


我只是把我的解决方案在这里的人将来可能需要它。我的测试平台是Windows 7,它会更好,如果你使用Linux或Mac OS X和解决方案,包含适用于Windows,Android的壳壳脚本蝙蝠脚本;他们的run.bat,logcat.sh,run_monkey.sh和run_logcat.sh。

 #的run.bat
亚行壳回声> /mnt/sdcard/logcat_log.txt#clean高达previous日志
亚行推logcat.sh到/ mnt / SD卡/#
启动庆典run_logcat.sh
启动庆典run_monkey.sh
暂停#logcat.sh
logcat的-v threadtime *:V> /mnt/sdcard/logcat_log.txt#run_moneky.sh
亚行壳猴子-p com.test.androidclient --throttle 300 -c android.intent.category.MONKEY -c android.intent.category.LAUNCHER -c android.intent.category.DEFAULT --pct-majornav 20 - 监控本机 - 崩溃 - 忽略安全例外 - 忽略崩溃 - 忽略超时--kill-过程后错误-s 220 -v -v -v 99999#run_logcat.sh
亚行壳SH /mnt/sdcard/logcat.sh&安培;


解决方案

  {尝试
    文件日志文件=新的文件(Environment.getExternalStorageDirectory()+/ LOGFILE.LOG);
    filename.createNewFile();
    字符串CMD =logcat的-d -f+ logfile.getAbsolutePath();
    调用Runtime.getRuntime()EXEC(CMD)。
}赶上(IOException异常五){    e.printStackTrace();
}

I just wanna to ask if it is possible to save android runtime error information in sdcard without device connected to PC? 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.

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. 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. 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.


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; they are run.bat, logcat.sh, run_monkey.sh and 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_moneky.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();
}

这篇关于如何保存的Andr​​oid运行时错误日志中的设备,而无需连接到电脑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆