views:

270

answers:

3

I'm testing an android application with a long running service. I'm using Eclipse and have the usb cord hooked up with the phone sitting next to me. Since it's a long ongoing service, I do some other work while it runs and check the logcat logs every once in a while to make sure everything is going as expected.

A few minutes ago I noticed the phone rebooting. I think it's done this before as it would explain some weird application behavior. I quickly switched over to Eclipse to see what happened and found that the logcat log was (it seems) cleared during the reboot. So there's no log of whether my app crashed (and took down the phone?!) or if there was some other problem that took down the phone and my app.

Is there anyway I can find out what happened? This is a development phone, so I don't know if it reboots/crashes often on its own, or only while my app is running. It's a Motorola Droid running Firmware version 2.1-update1.

Thanks for your help.

+1  A: 

I don't know of any way to do this. However, you could start up logcat in adb with adb logcat -v time > logcat.txt and then run your app again. If it crashes a second time, then you can go look at the output in logcat.txt on your machine.

eldarerathis
Note that file writes are buffered, so the very last words before rebooting may not be flushed to the file.
adamk
@adamk: Also a good point. Is there a cleaner way to do this (I'm guessing `adb bugreport`)?
eldarerathis
@eldarerathis: you guessed right :) - I used it a couple of times, and it proved useful. BTW - running `adb shell logcat -f file.txt` may be better (in the buffering sense) than just piping using the shell, but it's really just a guess.
adamk
I was able to catch a crash, and this line from the log: `08-12 11:22:50.568 E/mdm_panicd( 1002): Modem has reset, reboot system!` Thanks! This has helped.
Scott Saunders
@adamk: I'll have to test that sometime. I've got Unix `bash` syntax so stuck in my head that I just automatically use `>` without even thinking about it. Not to say that I don't love `bash`, of course.
eldarerathis
A: 

I have run into this problem as well. It should be possible to write an app that continuously saves the logcat output to a file on the SD card. There are apps on the market that display the logcat output, so I know it is accessible from within an application.

@djv, I wasn't able to find a /log directory in either root or /data on my phone.

Aaron C
+1  A: 

You can use adb bugreport, which should contain some information regarding a spurious reboot - for example, a kernel panic, last logcat entries etc.

Be warned, though: this tool outputs immense amounts of information, so you'll have to dig deep to find what you need.

adamk
Wow. That gave me 20,000+ lines. I'm sure it's great information, though I don't know what to do with it!
Scott Saunders
@Scott: I'd start by searching inside your app's package id, log tags etc. to see if there's anything related to your app.
adamk
I'm looking through it now. I'm not seeing anything from before the reboot, though. Maybe I waited too long? It's been about two hours since the last reboot.
Scott Saunders