DEBUGGING

Eclipse supports debugging your application on both the Android emulators as well as on real Android devices. When you press F11 in Eclipse, Eclipse will first determine whether an Android emulator instance is already running or a real device is connected. If at least one emulator (or device) is running, Eclipse will deploy the application onto the running emulator or the connected device. If there is no emulator running and no connected device, Eclipse will automatically launch an instance of the Android emulator and deploy the application onto it.

If you have more than one emulator or device connected, Eclipse will prompt you to select the target emulator/device on which to deploy the application (see Figure A-20). Select the target device you want to use and click OK.

If you want to launch a new emulator instance to test the application, select Window ⇒ Android SDK and AVD Manager to launch the AVD manager.

Setting Breakpoints

Setting breakpoints is a good way to temporarily pause the execution of the application and then examine the content of variables and objects.

To set a breakpoint, double-click on the leftmost column in the code editor. Figure A-21 shows a breakpoint set on a particular statement.

When the application is running and ...

Get Beginning Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.