Below are the steps to debug android code with Android Studio :
1. Put breakpoint (small red circle) at the line of code where you want to debug or investigate by clicking at the right of line number. in the example, I put breakpoint at line 22. see the picture below :
Put breakpoint at line of code that you want to debug. |
3. after app successfully installed, Just play with your app that will execute the line of code that has the breakpoint. In the example, I should click login button to execute the line of code that has breakpoint.
4. When the app run and want to execute the code at the breakpoint, it will stop before executing that line (line 22). Click step over like in the picture below to execute that line of code or press F8.
App will stop execute at breakpoint line. |
that is supplied by onClick method to know its value by pointing cursor arrow at v variable.
The purpose of debugging is to make sure that that line of code contains the right values that you expected. for example if v or intent is null, but you expected not null then that is the problem of error and you need to solve exactly at that line.
6. When you are done investigating the line at the breakpoint, you can resume executing the app by pressing the resume button at the top left of debug console (green triangle button).
Thank you for visiting our website. Just comment below if you have any question.
No comments:
Post a Comment