How to perform breakpoint debugging using Android Studio

Source: Internet
Author: User
Tags log log

Familiar with the development of Android children's shoes should not be unfamiliar to Android studio, it is one of the most common development environment of Android Development, in the program development, we often need to do breakpoint debugging, in Android Studio, how to carry out breakpoint debugging? Then let's take a look at the specific methods and steps.

Before you start debugging breakpoints, you need to compile the program you want to debug, and then follow the steps below to start debugging.

1. Set breakpoints

Select the line of code where you want to set the breakpoint, and click the left mouse button after the area of the line number.

2. Turn on the debug session

Click on the red arrow pointing to the bug, start to enter the debugging process.

The debug view appears below the IDE, and the red Arrow points to the line of code that is now stuck in the debugger, in method F2 (), line 11th of the program. The red arrow hovers over the area of the program's method call stack. In this area, the method used to execute the program to the breakpoint is displayed, the more the following method indicates the earlier the call is made.

3. Single-Step commissioning

3.1 Step Over

Click on the button pointing to the red Arrow, the program executes a line down (if the current line has a method call, this method will be executed to return, and then to the next line)

3.2 Step Into

Click the button pointing to the red Arrow and the program executes one line down. If the row has a custom method, it runs into a custom method (a method that does not enter the official class library). The steps are as follows:

Set breakpoints at Custom method send F1 (), perform debugging

Click

3.3 Force Step Into

This button can enter any method when debugging.

3.4 Step Out

If you enter a method (such as F2 ()) while debugging, and feel that the method is not a problem, you can use step out to jump out of the method and return to the next line of statements where the method is called. It is worth noting that the method has been executed.

3.5 Drop Frame

When you click the button, you will return to the current method's call (for example, the program will return to Main ()) and the value of all context variables will return to that time. You can jump to any of these methods as long as there is a parent method in the call chain.

4. Advanced Commissioning

4.1 Debugging across breakpoints

Set multiple breakpoints to turn on debugging.

To move to the next breakpoint, click for example:

The program runs a breakpoint to the next breakpoint between the code that needs to be executed. If the following code does not have a breakpoint, tapping the button again will run the program.

4.2 Viewing breakpoints

You can view the breakpoints you have set and set some of the properties of the breakpoint by clicking the button that points to the arrow.

Arrow 1 points to the breakpoint you have set, and arrow 2 can set a conditional breakpoint (when a condition is met, pause the execution of the program, such as C==97). After you finish debugging, you should delete the breakpoint you set at arrow 1 (after selecting the breakpoint you want to delete, click the red minus sign above).

4.3 Setting variable values

After debugging starts, the red arrow points to the area can assign a value to the specified variable (left mouse button to select the variable, right-click Pop-up menu select SetValue ... )。 This feature allows you to detect your conditional statements and loop statements more quickly.

5. Android Studio breakpoint debugging shortcut keys

Here are some of the shortcut keys that are commonly used when using Android studio to debug breakpoints during debugging:

Alt+f8 Check values when debugging

F8 equivalent to eclipse F6 jump to the next step

Shift+f8 equivalent to eclipse's F8 jumps to the next breakpoint, also equivalent to eclipse's F7 bounce function

F7 equivalent to eclipse's F5 is entering into the code

Alt+shift+f7 This is mandatory entry code

CTRL+SHIFT+F9 Debug Run Java class

CTRL+SHIFT+F10 Normal running Java class

Command+f2 Stop Running

The above is how to use Android studio how to conduct breakpoints debugging specific methods and procedures, when debugging breakpoints, you may wish to follow the above steps to go through, to deepen the mastery of each step.

Also recommended a new remote debugging tools-Cloud phone. Solve the product development process in the model is not complete, the bug can not reproduce the two difficulties, support breakpoint debugging, single step execution. Remote named row operations are supported.

Rich log log real-time output and video recording, full feedback and quick location bug, log filtering function, quickly reproduce the bug, positioning more accurate, timely before the/app of the quality of the hand tour to the best state, to avoid the problem caused by the online after the next frame and repeat the risk of submission.

At this stage to register as a cloud mobile phone users and improve the information can also get free experience opportunities.

Http://t.cn/R4jVeZX

How to perform breakpoint debugging using Android Studio

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.