views:

161

answers:

3

Assuming I didn't start in debug mode, is there a way to make the eclipse debugger automatically start if my app throws an exception inside the emulator?

Alternatively, is there a way to get a more useful error message out of the emulator (something more useful than "Sorry, your app terminated unexpectedly").

+1  A: 

I don't know how to trigger the debugger, but did you look at the stack trace when the error occurred, either in Eclipse DDMS (if it was already running) or using the "adb logcat" command?

http://developer.android.com/intl/zh-CN/guide/developing/debug-tasks.html

Luke Dunstan
Thanks, that helps. the logcat view shows up in eclipse, but I didn't see anything about my app until I filtered out everything except errors.
Seth
A: 

Yes, there is a button to add a Java exception breakpoint from the Breakpoints view in the Eclipse Debug perspective. See here for further details:

http://help.eclipse.org/galileo/topic/org.eclipse.jdt.doc.user/reference/views/breakpoints/ref-addexception_viewaction.htm

The emulator is emulating a real Android device. There is little point in displaying stack traces to an end user, hence the generic message. Use the LogCat view in the DDMS perspective.

Jeff Gilfelt
Breaking on exceptions would require that I started in the debugger. I want a way to link up the debugger on demand (like the windows "Do you want to debug?" dialog).
Seth
Ah, you're right. I don't think it's possible in normal execution mode without the debugger attached.
Jeff Gilfelt
A: 

Looks like you can almost do this in the DDMS perspective via the "Debug Process" button. It still won't break on demand if you aren't already in debug mode. And it's too late to debug if you're already looking at the "force close" dialog.

Seth