How to Create a New Android App

In my previous tutorial on Android, we learned about first setting up the Android Development Environment and then we learned about improving the performance of virtual devices so that we can develop and test our code in a faster way. In this tutorial, I am listing out steps you will be following to create an android app everytime. In between the steps, I will detail out the details and some tips that will help you whenever you are in doubt; hopefully.

The below sequential steps will create an android app named DemoApp, using the dev setup we created in my last post. Let’s start the fun.

1. Creating New Android Project

From the Eclipse main menu, choose File > ‘Android Application Project’ and click “Next >” to proceed to the wizard’s next page.

File - Android Application Project
File – Android Application Project

This will bring you a blank wizard for creating a new android application like the below:

Blank New Android Application ScreenBlank New Android Application Screen
Blank New Android Application Screen

Here fill in the following items.

  • For “Application Name” and “Project Name”, fill in DemoApp
  • For “Package Name”, fill in com.howtodoinjava.demoapp
  • For “Minimum Required SDK”, choose “API 11: Android 3.0 (Honeycomb)”
  • For “Target SDK” and “Compile With”, choose “API 19: Android 4.4 (Kitkat)”
  • Choose Theme “Holo Dark”
Filled New Android Application Screen - Wizard One
Filled New Android Application Screen – Wizard One

Then, click “Next >” to move to the next page of the wizard:

Blank New Android Application Screen - Wizard Two
Blank New Android Application Screen – Wizard Two

Leave all options selected as default for now and click “Next”. At this step, you will have to select the launcher icon for your app. All you have to select an image and wizard will do the rest like resizing it for different screen levels and storing them in appropriate places inside the project. Cool !!

I have selected an image like the below. You can choose any of your choices.

Android Create Launcher Icon
Android Create Launcher Icon

Now click Next. Here, you choose which template project you want to use as a starting point. Leave the “Create Activity” check-box checked, and choose “Blank Activity” from the template list.

Android Create Activity
Android Create Activity

Then, click “Next >” to move to the next page of the wizard and Fill in the following details:

  • For “Activity Name”, fill in DemoAppMainActivity
  • For “Layout Name”, fill in the main
Android Fill Activity Details
Android Fill Activity Details

At this point, you can click the “Finish” button to complete the wizard. Your new DemoApp project should appear in the Eclipse Package Explorer view like below.

Project explorer view
Project explorer view

2. Perform Some Minor Cleanup

The Android Developer Tools plugin will give you what it thinks are appropriate starting files for your app. Sometimes it is right, sometimes it is wrong. In our case, it may have added a library that we will not need to use directly, and we may as well get rid of that now.

Look in the libs/ directory of your project. If that directory exists and has a JAR in there (probably named android-support-v4.jar), delete it. However, leave the empty libs/ there.

3. Run the Project

Now, we can confirm that our project is set up properly by running it on a device or emulator.

Press the Run toolbar button (usually depicted as a white “play” triangle in a green circle). The first time you run the project, you will see a “Run As” dialog, prompting you to declare how you want to run the app:

Project run as Android App
Project run as Android App

Click on “Android Application” and click “OK” to proceed.

At this point, if you have a compatible running emulator or device, the app will be installed and run on it. Otherwise, Eclipse will start up a suitable emulator from the AVDs you created in the previous tutorial and then install and run the app on it.

Android running app
Android running app

Note that you will have to unlock your device or emulator to actually see the app running — it will not unlock automatically for you.

In the next tutorial, I will discuss the project’s contents in detail.

Happy Learning !!

Leave a Reply

Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.

Our Blogs

REST API Tutorial