Android hello world programming tutorial

It is tradition for most tutorials to start with a simple “hello world” program which simply displays the words, Hello World on the screen.  This tutorial will follow that tradition when creating your first Android program.  To get start select the File–> menu–>Android Application Project.

Android Project

Creating a new Android application

In the dialog box that follows enter the following information.

New Android Application

The Application Name is the name of the Application followed by the Project Name.  The application name is the name that your user will when running the app.  The project name is the name that Eclipse will use to keep track of your project.   The package name is the namespace for you app.  A package name must be unique which is why you will find that the word com starts first.  For example, com.suntimebox.helloworld will be unique.  The next app might be called music so therefore the package would be called com.suntimebox.music.  By using your organisation name you will be creating apps that are unique to you or your company.

The minimum required SDK is the lowest possible device that you want to support.  This means that you can still program for the latest devices but if you app is running on a previous device then some of the features might not be available when a user is using your app.  You can allow these features to be turned on and off so that older devices will still run your app be will be less feature rich that the new device.

In this case the minimum is Android 2.2 which is API 8 but we will be targeting API 18, Android 4.3 which is the highest level that our application will be tested with.  Compile with is the version that you are compiling your app with.  The default setting will always be the latest version so that your app will always optimise itself for the latest features.

The theme allows you to select the style and look of the app.  Leave the default setting of Halo Light with Dark Action Bar and click Next.

You can leave the next screen with its default settings.  Pay close attention to the Create Project in Workspace.  This is the location of your project files.  Click Next.

Configure the Android App Launcher

You can accept the default settings and click Next.  We will be configuring the launcher icon later but this is essentially the icon that will appear to your user when they select the app from their device.

Accept the default settings again for the Create Activity screen and click Next.  The activity can be thought of at a piece of paper that we will place buttons, text and images so that your user can interact with.

Creating the android activity

Click Finish for the Blank Activity screen but note the files that Eclipse is creating.  The Activity Name is MainActivity and the Layout name is activity_main.  This layout file will contain configuration information on how the applications buttons, images and text will appear on the screen and additional settings for this app which you will see later and you progress.

Eclipse will generate the necessary files in order to get your basic framework ready.  The first thing you need to do is to make sure that Eclipse has done this correctly which it normally does but just to bring everything up to date, right click on the HelloWorld project folder in the package explorer area.

Building the Eclipse Project

Your project should build successfully.  I have seen Eclipse in the pass to cause errors in the app by not generating some of the files correctly.  If you app is displaying errors follow these steps. Eclipse won’t build the project correctly.

Android Game Programming

Next Android Game Programming Week 2 – Android Emulator Day 1.0 >>