Android Studio

[Ch2-2] Android Studio Debugging. Types of Break Points

공급망관리 최선생 2019. 8. 12. 00:17

Before we jump into the debugging process of android, let's look at the types of breakpoints of Android Studio.

 

※ What are breakpoints?

- When running a program by using Android Studio, breakpoints tell the program to stop at a certain point or area. And be waiting for the user to decide the next move.

 

※ When to use it?

- If your program does not run at all or working in a way that you did not intend to, you might want to check the line or area that you suspect the most. In this case, you set a breakpoint before the line and see how each line works.

 

 

Types of Breakpoints

1. Line Breakpoints (LBP)

line break point

Line breakpoint is the red dot on the left side of the code "setContentView(R.layout.tablelayout_example);" 

 

How to set line breakpoints: click the empty area between the code line number (which is 11 in this case) and the actual code. (Simply try clicking where my LBP is)

 

Functions: the program should stop before running the line you set a line breakpoint

 

2. Method Breakpoints (MBP)

Simply setting a breakpoint on a method base. (not line base)

The little red diamond tells that the method breakpoint is set on "onCreate" method.

 

How to set method breakpoints: Click "run" tab and click "Toggle Method breakpoint"

 

Functions: Even if you try to set the method breakpoint on "setContentView(R.layout....);". the breakpoint will always be set on the method or class that obtains the line you try to set initially.

This means that if the source or line exists for a class or a method, the method breakpoint will find the method or class and set a breakpoint to stop reading any lines in the method.

 

 

3. Temporary Line Breakpoints (TBP)

How to set temporary line breakpoints: Click "run" tab and click "Toggle temporary line breakpoints".

 

Functions: As it says by its name, this enables breakpoints temporarily. When you try to debug the loop statement that repeats a certain process for many times. You might want to set a breakpoint that stops the program running once and continue without stopping when the second time loop statement runs. This is usually done by using a temporary line breakpoint.

 

4. Conditional Breakpoint (CBP)

How to set conditional breakpoints: After you set a simple LBP and right-click the red dot you set. and add conditions you want to use.

 

Functions: The breakpoint will work only when the conditions you added matches.

 

----------------------------

Since I am a programming noob, I do understand that some people think this is one of the useless things to remember. But by a rule of thumb, writers usually organize the most important things at the very beginning of their books. So this is certainly not an enjoyable part to study at this stage, but I better try to understand these minor things to safely continue the long-run study plan.