Android Studio Use Tips

Source: Internet
Author: User

Android Studio Development Debug Use

Android Studio debugging is also very convenient, general problems directly through as the DDMS Logcat can be done. As supports all features of DDMS like Eclipse. Here to say is the debugging of difficult problems, that is, breakpoint debugging.

First compile the program you want to debug.

Click Set breakpoint at line number as shown in 2. Then click to open the debugging session as shown in 1.

As shown, the Debug view appears below the IDE, and 1 points to the line of code where the debugger is currently stuck, and the 2 area is the program's method call stack area. In this area shows the method used by the program to execute to the breakpoint, the more the following method is called earlier. In this order presumably some Android in-depth understanding of a little Android system startup process know how these methods, how to the activity of the oncreate. Haha, speaking of the system. It's not a rip. 3 is a number of debugging buttons, shortcut keys placed directly on the above will be displayed. 4 and 5 are some variable observation areas.

In

Click the 1 point button, 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.

Click the 2 point button 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).

Click on the 3 button to enter any method when debugging.

Click 4 the role is if you enter a method (such as Debugfunc) when debugging, and feel that the method is not a problem, you can use 4 to jump out of the method, return to the method is used to the next line of the statement. It is worth noting that the method has been executed.

When you click the 5-point button, you will return to the current method's call to execute again, 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.

If you set multiple breakpoints, turn on debugging. To move across a breakpoint to the next breakpoint, click a 1 arrow, and the program will run a breakpoint between the next breakpoint and the code that needs to be executed. If the following code does not have a breakpoint, tapping the button again will run the program. Click on the arrow 2 to point to the button, you can see the breakpoint you have set and can set some properties of the breakpoint, as shown in. After debugging begins, in the variables area you can assign a value to the specified variable (the left mouse button selects the variable, the right-click popup menu selects the SetValue ... )。 This feature allows you to detect your conditional statements and loop statements more quickly. You can view the value of the trace variable by tapping the arrow 3 plus or by right-clicking on the debug code variable to add watcher.

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 Index==5). 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).

These are some of the debugging tips for using as

Android Studio Use Tips

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.