uwe seeler
uwe seeler

Reputation: 353

How to put a watch (see how a variable is modified) in Android Studio?

I don't know how to use a watch in Android Studio. I want to see how the value of a variable modifies through debugging. Does anyone know how to do this?

Upvotes: 34

Views: 50396

Answers (2)

Suragch
Suragch

Reputation: 512566

Assuming you have the debug tabs selected:

enter image description here

If you can't find the Watches View, it might be hiding in a few spots.

Check the right side:

enter image description here

If its not there, check the left side of the Variables tab:

enter image description here

And if you don't find it in those places, then you can right click one of the variables at a breakpoint and choose "Add to watches" (as described in the accepted answer). After that the Watches View should either appear or be in one of the places I described above.

Upvotes: 13

Miguel
Miguel

Reputation: 20153

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

Upvotes: 34

Related Questions