How to enable non-suspending logging breakpoints (APG-4)

How to enable non-suspending logging breakpoints (APG-4)

While debugging android apps, you often use log statements to trace a specific point.

These logs are normally not required in release versions, so you would need to manually delete them. It takes a lot of labor.


Android studio provides a fantastic feature to add and remove log statements using breakpoints.

To use it,

1. Place any breakpoint on a line by clicking on the gutter column (or use Ctrl + F8) and then right-click.

2. A pop-up menu will appear. Uncheck the suspend option and another expanded menu will appear.

3. Select the Evaluate and log option, then type a logging statement (you can also include variables)

No alt text provided for this image

Now, when you run the app in debug mode, your code will hit the breakpoint?but it won't halt execution. Instead, the evaluated statement will be printed into the Console window.

These breakpoints are not-suspending, so you can choose to keep them. Your code will only hit the breakpoints when you run the app in debug mode. You don't need to perform any further work for the release version.


However, if you wish to remove them all at once before release,

1. Press Ctrl + Shift + F8 to open the breakpoints dialogue box.

2. To select all breakpoints, use Ctrl + A.

3. Use Alt + Delete to remove the breakpoints you've selected.

No alt text provided for this image

#android?#androiddeveloper?#androiddevelopment?#androidstudio?#kotlin?#java


We also have an android developer community on WhatsApp where we enjoy learning and sharing everything android, including live sessions, interview preparation, job referral, tutorials, and Q&A. Join us if you're interested.

https://bit.ly/adc-whatsapp-1

https://bit.ly/adc-whatsapp-02?(Join this if the first group is full)

No alt text provided for this image
Sachin Saxena

Android Developer

2 年

Saved ??

要查看或添加评论,请登录

Rajesh Hadiya的更多文章

社区洞察

其他会员也浏览了