views:

494

answers:

2

I am a little bit new to developing for Android using Eclipse (Coming from a .NET/Visual Studio background). My biggest problem in developing Android app is "debugging" them. Every time the emulator throws an error, there is no message, no explanation of what caused the error. I basically have to keep doing trial/error until something works.

  • My question is: Is there a better way to analyze the error messages that emulator shows (basically some stack trace about Dalvik)!

  • Also, is it possible in Eclipse [when debugging] to move the debugging cursor backwards to re-evaluate a variable or "skip" some lines of code?

+3  A: 

Use LogCat view to see error/debugging messages. Regular console is of very limited help. Window->Show View->Other->Android->LogCat There on the top you will see some round buttons that basically can filter log from V (verbose) to E (error). You can't copy/paste from theLogCat window but you can save selected output to text file

DroidIn.net
Are you sure you can't select lines in the logcat window and copy/paste? I've done it in the past.
MattC
Actuall - if you highlight line(s) and hit Ctrl-C you indeed can copy it
DroidIn.net
+1  A: 

Regarding the error messages (I'm assuming these are the messages that show up in LogCat): I've found that analysing the error messages and working your way up the list until you reach code that is yours is the most effective way to work. Frequently (for me at least) the emulator will crash and break somewhere in the OS code (which you probably don't have the source for) but you can follow the LogCat messages back to your code and start to see where the problem is. The crash may appear to happen in the OS code, but the original cause is typically you passing something wrong to the OS.

Regarding going backwards in code: nope, at least not with the my Eclipse Ganymede install

Regarding skipping code: When your in debug mode under the Run menu you can select "Step Over" (skips going into a method) , "Step Return" to exit a method and "Run to Line" in addition to setting Breakpoints by right clicking. This causes the code to run, but you aren't single stepping through it. Otherwise the only way to "skip" lines of code is to comment it out. I believe you can also change the value of variables in the debugger, but I've never tried personally. This may give you the desired effect.

Will