Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there any way to conditional Debugging in android studio

Is there any way to have conditional Debug in android studio? for example I wanna go to debug mode when a specific variable value is. for example:

for(MyClass myclass: ClassList){
String title = myclass.gettitle(); // this is where break point is
}

Before that I do not need the debug mode. I just wanna examine the app on that exact value. for example when title="KickBoxing" in this case I should check the variable value and if it is not my required value I should press F9 to go to next value. maybe this takes 50 times to get to my desired value.

like image 292
Mahdi Avatar asked Oct 31 '16 11:10

Mahdi


People also ask

Can you set breakpoints in Android Studio?

View and configure breakpointsThe Breakpoints window lets you enable or disable each breakpoint from the list on the left. If a breakpoint is disabled, Android Studio does not pause your app when it hits that breakpoint. Select a breakpoint from the list to configure its settings.

How to debug C++ code in Android Studio?

Note: For Android Studio to detect breakpoints in your C or C++ code, you need to use a debug type that supports LLDB, such as Auto, Native, or Dual. You can change the debug type Android Studio uses by editing your debug configuration.

What are the different debug types available in Android Studio?

The debug types available include the following: Auto: Select if you want Android Studio to automatically choose the best option for the code you are debugging. Java: Select if you want to debug only code written in Java or Kotlin—the Java debugger ignores any breakpoints or watches you set in your native code.

How to debug an Android app without restarting it?

However, if you started an app by running it, you can attach a debugger to the running app without needing to restart it. To do this, click Attach Debugger to Android Process.

How do I debug an app in Visual Studio?

1 Set some breakpoints in the app code. 2 In the toolbar, select a device to debug your app on from the target device drop-down menu. 3 In the toolbar, click Debug . 4 If the Debug window is not open, select View > Tool Windows > Debug (or click Debug in the tool window bar), and then click the Debugger tab, as ...


1 Answers

It is possible to add a condition for a breakpoint. Add a breakpoint, as you normally do, and click with the right mouse button on it. You will be prompt with a dialog. In the condition you can put some java code.

E.g. you could put "kickBoxing".equals(title)

this way the debugger will stop on that breakpoint only when the condition is true.

enter image description here

(photo taken from http://javafortesters.com/)

like image 58
Blackbelt Avatar answered Sep 18 '22 01:09

Blackbelt