Is it possible to watch variables at runtime?

When your program has stopped on a breakpoint click the icon at the far right of the debugger menu (see image below). You can type in methods or variable names into this window and see what they would be.

enter image description here

You can type any expression you like (as long as it is within the scope of where you broke your code) and input any hard-coded values or objects all without re-running your project.

enter image description here

To add a variable to your watch list

Start by putting a break point in the class where you'd want to watch a specific variable. Run the code and once it hits your breakpoint from the Variables window frame you should see all of the variables that are accessible. Simply choose the one you'd want to watch and then right click and choose "Add to watches" from the drop-down.

enter image description here

Keep debugging and you should see the variable from the Watches window frame update when appropriate based on your code.

enter image description here


YES you can!

According to the Android Dev Summit '19, you can easily do that by disabling the Suspended flag in your breakpoint.

Then you can evaluate a log message to the console every time it gets the breakpoint, without suspending!

enter image description here

As you can see, my app fires a log to the console every time it gets to my breakpoint.

In other words, you can view variable changes at run time!