In this post I’m going to talk about one of the most important skills software developer should have – debugging and problem solving. If you’re experienced developer – then this post might not be interesting so much, but for beginners I hope you find it interesting and helpful
So I have an app with few bugs and going through debugging process in text is kind of silly, it would be way too much text and code. I personally don’t like long posts and reading so much, so text version is going to be about debugging overall and video is about actual example of me debugging an app
Plus that app isn’t mine, so I talk about way to find issues in general. That’s really useful to go and debug someones apps
There’s at least two ways to debug: with log cats and with break points. Both are interchangeable, so you can use ether of them or maybe even both. I personally use logs always, they give very readable output, I can extra text to it to give some more meaning
So there’s many different method from Log class, I use d() always and don’t miss out on some readability.
Log.d(LOG_TAG, "filter() called with: " + "charText = [" + charText + "]");
a shortcut for this is logm + TAB, it prints out method arguments, logd is just a fast way to create logs and logt for creating log tag constant
And then you select debug mode, add that filter
Breakpoints aren’t something new, you might’ve used them before in web or any other platform. They give more full overview of an app in that time, since app stops at that break point and you see values of each variable. And creating them is really easy, just click on the side of code editor and start app in debug mode
When your app reaches that line of code it will stop and you’ll see this kind of output. Or could be more for you
On the right side there’s Variables tab, to resume app you need to click on green play button. So it really doesn’t matter which way you prefer, they both made for the same purpose.
That’s basically it, if you want to watch me debugging an app – check the video above. Thanks for reading, if you like this stuff – subscribe and share with friends!
Formerly an Android developer, lately picked up some Flutter. This blog is everything that I find exciting about Android and Flutter development. Stay tuned and hope to see you again!