General debugging tips and tricks
Android Studio provides us with a variety of features that help us debug our code. Some of the features are listed in the following points:
- Logcat
- Stack Traces
- Breakpoints
Let us look at each of these closely.
Logcat
Logcat in Android Studio displays log messages in real-time from our apps. Each log message has a priority level attached to it. We add log messages in our app using the Log
class. This class offers different priority levels that we can use to log messages. The different priority levels are as follows:
- V: Verbose (lowest priority)
- D: Debug
- I: Info
- W: Warning
- E: Error
- F: Fatal
- S: Silent (highest priority)
We use the preceding letters to specify the log level. For example, if we want to log a message with the debug level, we will use the following code:
Log.d("TAG", "Message")
The first parameter is the tag. The tag is used to identify the source...