Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)

(gtxtreme123) #1
Running on the Emulator

Figure 1.17  Updating emulator properties


Once you have an AVD, you can run GeoQuiz on it. From the Android Studio toolbar, click the run
button (it looks like a green “play” symbol) or press Control+R. Android Studio will find the virtual
device you created, start it, install the application package on it, and run the app.


Starting up the emulator can take a while, but eventually your GeoQuiz app will launch on the AVD
that you created. Press buttons and admire your toasts.


If GeoQuiz crashes when launching or when you press a button, useful information will appear in
the Logcat view in the Android DDMS tool window. (If Logcat did not open automatically when you
ran GeoQuiz, you can open it by clicking the Android Monitor button at the bottom of the Android
Studio window.) Look for exceptions in the log; they will be an eye-catching red color, as shown in
Figure 1.18.


Figure 1.18  An example NullPointerException at line 21


Compare your code with the code in the book to try to find the cause of the problem. Then try running
again. (You will learn more about Logcat and debugging in the next two chapters.)

Free download pdf