vikzilla
vikzilla

Reputation: 4138

How to print out values while debugging

In Xcode I am able to "po" any values while debugging. Is there a way to do this in Android Studio?

For example, if I hit a breakpoint and want to print out certain values in realtime as opposed to having to use Logs in my code?

Upvotes: 30

Views: 14017

Answers (4)

Yan Jun Li
Yan Jun Li

Reputation: 1

If it's a c/c++ project, you still can use lldb command in Android Studio. Here's the official document. When you hit the breakpoint, you will see a tab named "lldb" next to the variables tab.

Upvotes: 0

Amir
Amir

Reputation: 16587

You can do the following steps:

1- Set BreakPoint in the line you want to evaluate Ctrl+F8.

2- Run your code in debug mode or press Shift+F9.

3- When reached to the BreakPoint press Alt+F8 or click on the following button.

enter image description here

4- Then type your value in text-field and click on the Evaluate button.

enter image description here

References:

Upvotes: 17

Kushal
Kushal

Reputation: 8478

When you hit debug point, there are two ways to check values :

(1) Add Watch for any variable

enter image description here

(2) Hover over any variable, the value will be displayed there

Upvotes: 5

asherbret
asherbret

Reputation: 6018

Use Watches. It gives you the ability to evaluate expressions.

Upvotes: 10

Related Questions