CHAPTER 6: Android Screen Design: Writing to the Display Using Activity and View 207
Next use the Run As ➤ Android Application menu sequence and see if you can get the application
to run. As you can see on the right side of Figure 6-36, the Hello Universe application crashes (stops
running, as per the error message in the emulator).
The probable cause of this crash is most likely passing a numeric value to the .setText( ) method call,
which is expecting a String (text) value, and most likely Java is not “casting” the numeric value into
a text value for you, and so the application crashes. When your application crashes, you can use the
LogCat to investigate what happened. Let’s do that next.
Using the LogCat
Let’s use this as an opportunity to see how to use the LogCat error log catalog utility to see exactly
what is crashing your application. Pull up the separator between the main editing pane and the error
tabs at the bottom of the IDE, to give some room to the LogCat tab to display its results, as is shown
in Figure 6-37.
Figure 6-37. Using the LogCat utility tab to diagnose where the fatal app error is located in the code (Line 21)