Usage of Android Studio Debugger

Reading Time: 1 minute

Before starting with new advanced topics in Android Studio, let’s learn usage of Android Studio debugger first. For example, if we want to add onClick method for some button, we can do it by open corresponding xml file (content_main.xml for example), add onClick declaration and then click on it and wait on bulb to show. Then choose Create onClick event handler.

Create-onClick-Event-Handler

Code signature of our method is automatically generated. Now, write code with code template, by pressing CTRL+J in Windows platform.

Code-Template-Android-Studio

Then click to generate break point.

Insert-Break-Point-Android-Studio

Run application in debug mode.

Debug-App-Shift-F9

And see what is happening.

Run-Android-Studio-in-Debug-Mode

We can also select any variable in the code, then right click and choose “Add to Watches”

Add-to-Watches

We can also set conditional break by right click on break point and setting up condition.

Conditional-Break

We can also start Android Device Monitor

Android-Device-Monitor

From: Tools→Android→Android Device Monitor

 

 

External links:

Usage of Android Studio Debugger on Stackoverflow

Tagged with: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*