In my previous tutorial on Android, we leaned about first setting up the Android Development Environment and then we learned about improving the performance of virtual device so that we can development and test our code in 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 detailing out the details and some tips you will help you whenever you will be in doubt; hopefully.
The below sequential steps will create android app named DemoApp, using the dev setup as we created in my last post. Let’s start the fun.
Step #1: Creating the Android Project
From the Eclipse main menu, choose File > ‘Android Application Project’ and click “Next >” to proceed to the next page of the wizard.
This will bring you a blank wizard for creating new android application like below:
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”
Then, click “Next >” to move to the next page of the wizard:
Leave all options selected as default for now and click “Next”. At this step you will have to select the launcher icon for you 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 project. Cool !!
I have selected an image like below. You can choose any of your choice.
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.
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 main
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.
Step #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 it has a JAR in there (probably named android-support-v4.jar), delete it. However, leave the empty libs/ there.
Step #3: Running 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:
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, then will install and run the app on it.
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 next tutorial, I will discuss about the contents inside the project created in some detail.
Happy Learning !!