Hello World on Android
In respect of the age-old tradition, our very first application for Android will be a “Hello World”. We will use Eclipse IDE and the Android Plug-in to complete this task. So, fire up Eclipse and let’s create our first application in 3 steps.
Step 1:‘File > New Project’, expand the Android options. Select ‘Android Project’ and then click ‘Next’ (see Figure 22).

Figure 22: Selecting a New Android Project.
Step 2: We now need to provide some information about the project (See Figure 23). Let’s start with the project name — ‘HelloAndroid’. Select a Build Target of Android 2.2. The Application also needs a name — call it ‘HelloAndroid’. Every application in Android has a package name — call it ‘apc.examples’. The package name must have a dot in it due to the naming conventions that are mandated by the Android platform. Every Android application is made up of Activities that correspond to the various screens in the application. We will create one primary activity — ‘HelloAndroidActivity’ (this should be automatically created for you). Leave the rest of the fields unchanged. Click ‘Finish’.

Figure 23: Providing information about an Android project.
Step 3: Once the project is created. Select ‘Run > Run’ (or click the Green button with a little arrow). Since it is the first time we are running an application, Eclipse IDE will ask a ‘way’ to run the application that you have just created. Select the ‘Android Application’ option and click ‘OK’. This will launch the Android emulator, and run the Droid2.2 virtual device that we created earlier. Eclipse plug-in will search for the most appropriate virtual device to run the application, if more than one compatible virtual machine is found, it will ask the user to select the device that they want to target.

Figure 24: Eclipse IDE requests the configuration to use when running an application.
The console view (at the bottom of Eclipse IDE) will show progress information. The application itself is first packaged as an APK file (Android Package), and deployed to the virtual device. The Eclipse Android plug-in then launches this application. In order to exit the application, press the Back button on the emulator (curved arrow button).

Feel free to explore the files in the Hello Android project. Android development is built around a set of simple conventions to help organise a project and increase productivity. We will explore these conventions and build a slightly more interesting application in the next part of the masterclass series.
Previous: Installing the Eclipse Plugin
Next masterclass: Exploring Android Development tools and conventions (Published October 13, 2011)