In the debugging perspective, we see the syntax errors, warning, console messages, run-time errors, variable transition (if breakpoint is used) and LogCat. LogCat is useful to trace any activity happening inside the device or emulator. The following screenshot shows the window to list all code problems, such as warnings or syntax errors:
A sample of console messages from the ADB is listed in the following screenshot. As a java person, we would be tempted to use System.out.println()
to split out message and objects' values; which are shown in the LogCat view, however it is advisable to use Log
class for this purpose, reason being we can filter, print different colors and define log types. This could be one way of debugging your program, by displaying variables' values or parameters. To use Log
, import android.util.Log
, and use one of the following methods to print messages to LogCat:
v(String, String) (verbose) d(String, String...