Android Getting Started

There are many beginner tutorials out there and the articles at developer.android.com do a pretty good job already. What I will show you instead is getting started quickly and progressively move towards a real working application with practical use instead of just a Hello World application.

Goals

By the end of this article, we will have created a simple Android application and learn a few basics of an Android project.

Setup

You will need the following at the very least to get started:

You can also use Eclipse stand-alone instead of the Android version but this tutorial will not cover this.

Creating a Project

Like any Eclipse based IDE, create a new project by clicking:

1. File > New > Android Application Project
2. In the New Project screen, fill in the name of your project and namespace.

android new project tutorial

3. For now, click Next through the screens leaving all defaults selected
4. On the last screen with the Activity configuration, take note of the fields:

  • Activity Name: MainActivity (assuming defaults)
  • Layout Name: activity_main (assuming defaults)

android new project activity

5. Click Finish on the last screen

The Project Structure

After the project is created, there are several pieces automatically created, which we will go over briefly:

1. MainActivity: This is the same activity listed on Step 4 when creating a project. Android defines an Activity as “a single, focused thing that the user can do”. I like to think of an Activity as a window/screen/frame that contains all the pieces for a main purpose/function. Development begins here and the UI layout is also associated here as seen below in the setContentView call.

 
 
2. res/layout/activity_main.xml: This is the layout for MainActivity which allows for UI design and building. If you are using the ADT version of Eclipse, there will be a Graphical Layout tab and the XML tab view. Play around with the Graphical Layout by dragging items from the palette and see how they are represented in the XML, i find this is a good way to learn.

android project layout xml

 
 
3. AndroidManifest.xml: This is the project definition file, that defines everything from the application’s name, version, starting activity, and icons. You will be revisiting this file again soon enough because we will need to enable permissions the application needs.

There are many more parts to the Android project but these are the main ones you will have to care about for now. If you right click, Run/Debug your application now, you will see a simple Hello World on a blank screen.

Running the Project

The ADT comes with tools and emulators, to run the project on. To begin, you should first setup your project’s launch configuration to always prompt for a device. This allows you to select an emulator or an attached Android device which is a good way to start. To do this:

  • 1. Right click on your project, click Properties
  • 2. Go to the Run/Debug Settings
  • 3. Select the configuration in the list, and click Edit
  • 4. In the launch configuration, click the Target tab
  • 5. Change Deployment Target Selection Mode to ‘Always prompt to pick device’

android new project launch

There are a few things here of interest too, you should see all your AVDs/emulator (Android Virtual Device) here that you have created.
When you run/debug your application, you will now be prompted to select an AVD or an attached device.

If you want to create a new AVD, please read lower on the sub topic ‘Creating an AVD’

 
 

Creating an AVD

To create a new AVD, otherwise known as an Android emulator follow these steps:

  • 1. In ADT, click Window, Android Virtual Device Manager
  • 2. In the screen that shows up, it should display all existing AVDs, edit one or click New
  • 3. Fill out your AVD parameters and details

 
 

Next Steps

As promised, we don’t want to be stuck on a Hello World application because many developers get lost on what to do next. Here are a few suggestions on moving onto the next step.

Leave a Reply

Your email address will not be published. Required fields are marked *