Your First Android Project

67

Chapter 3: Your First Android Project

8. Click the Create AVD button.

The Android SDK and AVD Manager dialog box should now look like Figure 3-12. Figure 3-12: The recently created AVD in the Android SDK and AVD Manager dialog box.

9. Close the Android SDK and AVD Manager dialog box.

AVD nomenclature Be careful when naming your AVDs. Android is available on many devices in the real world, such as phones, e-book readers, and netbooks. A time will come when you have to test your app on various configurations; therefore, adhering to a common nomenclature when creating your AVDs can later help you recognize which AVD is for what purpose. The nomenclature I tend to follow is the following: {TARGET_VERSION}_{SKIN}_ {SCREENSIZE}[{_Options}] In Step 3 of the example in this section, you used the name of 2_2_Default_HVGA. This AVD will have a TARGET_VERSION of Android 2.2. The version name 2.2 is transformed into 2_2. The underscores are used in place of periods to keep the name of the AVD combined. Creating an AVD name as a single combined word helps when you’re working in advanced scenarios with AVDs via the command line. The SKIN is the name of the skin of the emula- tor. Emulators can have various skins that make them look like actual devices. The default skin is provided by the Android SDK. The SCREENSIZE value is the size of the screen with regard to the Video Graphics Array VGA size. The default is HVGA. Other options include QVGA and WVVGA800. 68 Part II: Building and Publishing Your First Android Application You may receive an error message after you create your AVD. This message may say Android requires .class compatibility set to 5.0. Please fix project properties. If this happens to you, you can fix it by right-clicking the project in Eclipse and choosing Android Tools➪Fix Project Properties from the context menu. You’ve created your first Android virtual device. Congratulations Creating Launch Configurations You’re almost at the point where you can run the application. A run configu- ration specifies the project to run, the activity to start, and the emulator or device to connect to. Whoa That’s a lot of stuff happening real quickly. Not to worry; the ADT can help you by automating a lot of the key steps so that you can get up and running quickly. The Android ADT gives you two options for creating launch configurations: ✓ Run configuration: Used when you need to run your application on a given device. You’ll use run configurations most of the time during your Android development career. ✓ Debug configuration: Used for debugging your application while it’s running on a given device. When you first run a project as an Android application by choosing Run➪Run, the ADT automatically creates a run configuration for you. The Android Application option is visible when you choose Run➪Run. After the run con- figuration is created, it’s the default run configuration, used each time you choose Run➪Run menu from then on. Creating a debug configuration You shouldn’t worry about debugging your application at this point because you’ll be debugging it in the near future. Creating a run configuration Now it’s your turn to create a run configuration for your application. If you’re feeling ambitious and decide that you’d like to create a run configu- ration manually, follow along here. Don’t worry; it’s very simple. Follow these steps: 69

Chapter 3: Your First Android Project