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?
-
2This VERY common debugging technique does not seem to be supported by intellij or android studio. And they think these are professional tools! (Intellij seems to think that a "watch" means variables that you commonly want to see, which is actually pretty silly. We want the debugger to break when a variable changes! THAT is what a watched variable is for.) – SMBiggs Sep 14 '19 at 20:19
-
1@SMBiggs I agree it should be easier, but you can setup what's called a "watchpoint" to break when a variable changes. https://www.jetbrains.com/help/idea/2016.3/creating-field-watchpoints.html – jj. Nov 03 '20 at 22:55
-
@jj. Good to know--I'll try it out soon. This could be a real solution. – SMBiggs Nov 09 '20 at 16:53
2 Answers
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.
Keep debugging and you should see the variable from the Watches window frame update when appropriate based on your code.

- 19,793
- 8
- 56
- 46
-
1And if you can't see watches window >> restore default layout Shift + F12 – Eftekhari Aug 27 '16 at 14:36
-
3Is there a way to see where and when it changes the value ? Without setting break points. I have a problem where I know the places it supposed to change, and with brake points I see that the value is correct, but then jump to the next break point and the value is already wrong. And jumping line by line does not seem optimal. – paakjis Jan 05 '17 at 07:18
-
@paakjis you can set Java Field Watchpoints: run-->View Brakepoints->"+" button on top left corner-->"Java Field Watchpoint". Set your class and field names in the dialog. – Gregory Stein May 16 '17 at 11:17
-
how do i see watches without setting a breakpoint? For instance, I want to see the current value of a static member of a class. In the watch field it doesn't show any value. – Michael Sep 23 '17 at 23:43
-
Assuming you have the debug tabs selected:
If you can't find the Watches View, it might be hiding in a few spots.
Check the right side:
If its not there, check the left side of the Variables tab:
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.

- 484,302
- 314
- 1,365
- 1,393
-
Without adding breakpoints, is that possible? My Frames, Variables and Watches windows are empty and clickng "add" in watches does nothing – NaturalBornCamper Dec 18 '17 at 03:39
-
1@NaturalBornCamper, If you don't add a breakpoint, there is nothing to watch, is there? – Suragch Dec 18 '17 at 03:50
-
Exactly, but I was hoping there was a way to add a watch variable by right-clicking on it before debugging, without having to use breakpoints.. – NaturalBornCamper Dec 18 '17 at 15:22
-
@Suragch I think OP is talking about live view of a variable. It's a common way to debug. – sprajagopal May 20 '21 at 06:43