Hello readersJ!! Hope you are enjoying learning android with us. This tutorial will help us in a better way as we have used eclipse as our development platform. Let us not waste time and start getting the overview of debugging environment.
13.2.1 Eclipse tools
Integrated Development Environment (IDE) like Eclipse is a perfect way of debugging android applications. Android Developer Tools (ADT) plugin is a user-friendly development environment which is associated with IDE. All of us are aware of the terminology WHAT YOU SEE IS WHAT YOU GET (WYSIWYG) interface. Android Development Tool plugin includes WYSIWYG user interface. It include the tools which are required to convert resource files responsible for layout into a form which are required to build an android executable.
220.127.116.11 Run Configuration
For each android application there is a separate profile corresponding to run configuration. Run configuration tells Eclipse the way to run the project, start the Activity, and whether to install the application on the emulator or a connected device. When the application is first created, ADT automatically creates a run configuration for each application. Although this run configuration can be customized and we can create a new run configuration or edit an existing run configuration. We can select Run-> Run configurations… Following snapshot shows the path for Run Configurations
Figure Run Configurations
Inside Run Configurations we have three more options and they are as follows:
- Android: It specifies the project and activity to launch
- Target: Using this option we can choose the virtual device in where you intend to run the android application. When we intend to run the application on emulator we specify the parameters here, in other words we specify the launch parameters here like network latency and speed, etc. We get a realistic simulation of linking conditions where we can test the application appropriately.
- Common: It specifies where the run configuration settings are saved and whether the configuration is displayed
Figure Tabs in Run Configurations
By setting breakpoint we can pause the execution of the application and then verify the content of variables and objects. We can set a breakpoint by giving double-click on the leftmost column in the code editor. A breakpoint is set when a small blue circle is present on that line. When we ruin the application and the first breakpoint is reached, Eclipse will display a Confirm Perspective Switch dialog. In other words, we developers can also run applications in debug mode and it is absolutely legal to insert breakpoints to freeze an application in run-time. Debug perspective is going to display the source file in a window along with few other windows including variables, breakpoints, outline, etc. For embedded programmers, using breakpoints is a standard debug method. It is a powerful method to chase down complicated bugs and unexpected behavior as we have the ability to stop at an instruction, see variable values in memory, and modify values in run-time or step through functions.
Figure setting a breakpoint
At the point of execution it will give you certain options and some of them are:
- Step Info: We need to press F5 to step into the next method call/statement
- Step Over: We need to press F6 to step over the next method call without entering it
- Step Return: We need to press F7 to return from a method that has been stepped into
- Resume Execution: We need to press F8 to resume the execution
If you could remember we encountered numerous run-time exceptions that prevented our program from continuing when we used to develop application, Some of the runtime exceptions are as follows:
- When we fail to specify the required permissions required by our application
- Exceptions related to Arithmetic operation
- When we try to access an object which is null i.e. Null reference exception
Hey guys!!! I know it is boring but it is important to know few concepts as we have used Eclipse and you will use eclipse in future as well. Congratulations we are done with this section. See you in the next sub-section. Till then keep practicing. Happy App developing !!!