Frage

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_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 &"
War es hilfreich?

Lösung

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();
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top