By Barry Burd

After you have created your first Android project, you will need to run it. To kick your new app’s tires and take your app around the block, do the following:

  1. Select the app’s branch in the Package Explorer in Eclipse.

  2. In the main menu, choose Run→Run As→Android Application.

    As a result, the Console view displays several lines of text. Among them, you might find the phrases Launching a new emulator, Waiting for HOME, and (as shown in the figure) Success!

    image0.jpg

    In the lingo of general app development, a console is a text-only window that displays the output of a running program. A console might also accept commands from the user (in this case, the app developer). A single Android run might create several consoles at a time, so the Console view in Eclipse can display several consoles at a time.

    If the material you see in the Console view in Eclipse is nothing like the text shown in the figure, the Console view may be displaying the wrong console. To fix this problem, look for a button showing a picture of a computer terminal in the upper-right corner of the Console view, as shown in this figure.

    Click the arrow to the right of the button. In the resulting drop-down list, choose Android.

    image1.jpg

  3. Wait for the Android emulator to display the Device Locked screen, a Home screen, or an app’s screen.

    First you see the word ANDROID as though it’s part of a scene from The Matrix, as shown in the figure.

    image2.jpg

    Then you see the word ANDROID in shimmering, silvery letters, as shown in this figure.

    image3.jpg

    Finally, you see the Device Locked screen, a Home screen, or an app’s screen, as shown in this figure.

    image4.jpg

  4. Remember: Wait for the Android emulator to display the Device Locked screen, a Home screen, or an app’s screen.

    The Android emulator takes a long time to start. For example, on a 2 GHz processor with 4GB of RAM, the emulator takes a few minutes to mimic a fully booted Android device. You need lots of patience when you deal with the emulator.

  5. Keep waiting.

    While you’re waiting, you can search the web for the phrase Android emulator speed up. Lots of people have posted advice, workarounds, and other hints.

    When the emulator is finally displaying the Device Locked screen, it’s time to proceed. . . .

  6. If the emulator displays the Device Locked screen, do whatever you normally do to unlock an Android device.

    Usually, you unlock the device by sliding something from one part of the screen to another.

  7. See the app on the emulator’s screen.

    This figure shows the running of the Hello World app in Android. (The screen even displays Hello World!) Eclipse creates this tiny app when you create a new Android project.

    The Hello World app in Android has no widgets for the user to push, and the app doesn’t do anything interesting. But the appearance of an app on the Android screen is a good start.

    image5.jpg

Don’t close an Android emulator unless you know that you won’t be using it for a while. The emulator is fairly reliable after it gets going. (It’s sluggish, but reliable.) While the emulator runs, you can modify the Android code and choose Run→Run As→Android Application again.

When you do, Android reinstalls the app on the running emulator. The process isn’t speedy, but you don’t have to wait for the emulator to start. (Actually, if you run a different app — an app whose minimum required SDK is higher than the running emulator can handle — Android fires up a second emulator. But in many developer scenarios, jumping between emulators is the exception rather than the rule.)