Press F8 to resume running without stepping. Resume: Done with this little session of debugging and want the app to start running again (until the next breakpoint is reached)? Then use the Resume feature. The current method will finish up and you will pop up to the next line of execution after that method has returned so you can continue debugging.
Step Return: Use this feature if you are in the middle of stepping into a method, and are past the area of the method you wanted to inspect.
Step Over: Use this feature to move to the next line of code on the same level as the previous one. If this method is well tested and you know it will return the right result, then you probably don't need to step into it, but instead step over it to the next code line on the same "level" as the previous one. Use this if you think the method you are currently executing needs debugging. Step Into: Use this feature to move deeper into your code by moving into method code. The most common debugging features in Eclipse that you will need in order to step through your code are: A good place to set your first breakpoint would be in the onCreate() method of your Activity. A little magnifying glass will appear next to the line of code when the breakpoint is set. You can also click on the line you want a breakpoint on and hit Control-Shift-B. I like to find the line I want to set a breakpoint on, and then right-click on the vertical blue band to the left of the code line and select Toggle Breakpoint from the menu or just click on the band itself to create a breakpoint, toggle it, and then remove it. Ok, now we're ready to step through our code.įirst, let's set a breakpoint in the code. Double-click on the activity class file associated with your application to open it, then switch back to the Debug perspective and you'll now see that the file is displayed in the middle pane of the Debug perspective. Switch to the Java perspective by clicking on the Java button in the top right-hand corner of Eclipse. Let's work through a quick example of debugging with Eclipse using the application you just launched.įirst, we need to get set up since there's nothing wrong with our code and the Debugger hasn't stopped automatically at a problem. You've got a panel in the middle of the Debug perspective that displays the code currently being executed.Īt the bottom of the Debug perspective, you've got two diagnostic panes: the LogCat pane which displays logging output from the emulator or device, as well as the Console pane that shows higher level console output from DDMS. Breakpoints are locations in your code that you flag where you want your debugger to pause execution so that you can methodically step through your code line-by-line and figure out what's going on. In the right-hand corner, you've got a panel that allows you to inspect variables and manage breakpoints. This is where you find the debug toolbar that allows you to attach and detach the debugger and step through the code. You've got a panel in the top left-hand corner called Debug, that shows your application, threads.
You can, of course, move them around if you don't like how they are set up. The Debug perspective has several panes of information. We usually name our Debug Configurations with the project name to avoid confusion, but you can name it whatever you would like. button, pick the Android project you want to debug, and then click OK. To create a debug configuration for your application within Eclipse, choose Run, Debug Configurations.ĭouble-click on Android Application (or right-click and choose New). Debug configurations are created much the same way, but are used to configure the options for launching and debugging applications.
In the Android Sample Apps tutorial in this series, you learned how to create a Run configuration in Eclipse. If you are not prepared, see the previous tutorials in this series. Also, you should know how to create a simple Android application (Hello World will suffice) in order to complete this tutorial. This tutorial is for the Java developer just getting started learning Android app development, who is somewhat familiar with Eclipse, and who has installed the Android SDK and the Android Developer Plugin for Eclipse.
This series of Android tutorials is meant to help you build the skills and confidence necessary to build high-quality Android apps. In this tutorial, we will explore the core set of debugging tools that new Android app developers need to be aware of in order to create and perfect their apps.