Android Hello World: Setting Up Your First App in the Development Environment

androidhelloworldReady to start developing for Android?

Let’s jump right in by creating a simple application. This guide will take you through creation of a default app to say hello world. And as soon as you’re comfortable proceeding, you can keep learning from your own home with an online course that teaches beginning Android development.

Step 1. Install and run the Android developer Tools

Do you already have the development environment installed on your computer? If not, you’ll be glad to know that the process is very simple. Head over to the download page on the Android developer site, and you should see a link for the package specific to your operating system.

The resources will download in a zip file, and as soon as that download is complete, simply extract it to a location that makes sense for you and that you can access easily. And that’s it. To fire up the program, go in to the Eclipse folder and run the executable file labeled “Eclipse.”

Step 2. Create a workspace and open the IDE

When you first open the developer kit, you will be prompted to select a workspace. You can select the default location that the application creates for you, or you can browse for a location and create a new folder.

For the purpose of this exercise, create a new workspace called helloworld. The welcome screen will appear, which you can close. This takes you to the main screen in the development environment

Step 3. Create a new Android application project

You are now in the Android development environment. In the package explorer pane at the left, you can create your new Android app. Right click inside the pane, and click “new” in the popup menu. A new dropdown will appear, and you will want to select the second option, “Android Application Project.”

A new dialog box will appear, and it will allow you to select parameters for your app. For this app, fill out the boxes as they are completed in the following image:

You will change these parameters, of course, based on the type of app you are developing and which versions of Android you want the app to run on. It’s important to give the app a unique identifier, and generally the application name should begin with an upper case letter. You will generally want the target SDK to be the latest android version, and you can change the minimum required SDK based on the oldest version you want your app to be compatible with.

Finally, you can change the theme to suit the style you want for your app.

When you have finished filling out these fields, click next. A second screen will come up with additional options.

On this screen, you will choose some additional configuration options. For the purpose of this app, uncheck “create custom launcher icon.” This will create a default launcher icon. Leave the other two defaults, “Create activity” and “Create Project in Workspace” checked. Then click next.

On the next screen you will select preferences for the activity you are creating. Stick with the default in this instance, “Blank activity” for this instance, but you can read through the additional options to get familiar with them.

You will then reach a final screen that allows you to name the activity, and you can leave this with the default settings for this exercise. In the future, when you are building out multiple activities for an app, you will want to put further consideration in to what you name these activities.

Step 4. Understand the program interfaces

After you have completed the setup for your application, you return to the interface to find that you now have your “hello world” already set up. You didn’t even need to undertake any programming! Of course, you will want to take a look through the different screens to understand the elements. Then when you feel ready, you can get started on creating a more sophisticated “hello world” that responds to user input. A beginning course on Android development will have you ready for this within the first few lessons.

MainActivity.java tab

You created an activity to program in Java when you set up your “hello world” app, and this is where you undertake the programming for that activity. As soon as you finish the setup, this is the default tab you will land on.  As it is currently designed, the code defaults to create a public class for you and import the basic elements you will need.  It should read as follows:

package com.testapp.helloworld;

 

import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

public class MainActivity extends Activity {

   @Override

   protected void onCreate(Bundle savedInstanceState) {

       super.onCreate(savedInstanceState);

       setContentView(R.layout.activity_main);

   }

   @Override

   public boolean onCreateOptionsMenu(Menu menu) {

       // Inflate the menu; this adds items to the action bar if it is present.

       getMenuInflater().inflate(R.menu.main, menu);

       return true;

   }

}

As you begin working in Android, you will want to have a basic understanding of Java. You can complete a course that will teach you to work with Java specifically within the Android environment.

activity_main.xml

When you switch tabs to view the app’s layout, you will see a graphical interface that allows you to work easily by dragging elements on to the application. When you click on an element in that screen, you see that element’s xml properties in a pane to the lower left. Click on the default “hello world” textview element to review its properties.

Notice also that at the bottom of the graphical layout, you can view the xml for the application’s layout. If you click on that tab, you will see the following in the interface:

You can quickly change xml parameters in this view. Which is a great option to work quickly in the development environment.  If you would like a brush-up on working with xml, and particularly, using xml in javascript, a course on xml could do you some good as you start developing in Android.

Step 5. Refine your app as you learn new skills.

If you followed this tutorial, you created a simple application to say hello world in Android. You should now have the development environment up and running, and you should have a good idea of what you are looking at inside of it.  As you advance your programming education, you can return to this basic app to try out new code. Enjoy the process, and look forward to creating some great new Android apps!