Android Application–Creating the first Application

Guys, lets start Android magic!

Go to the eclipse location (C:\Development\adt-bundle-windows-x86\eclipse) and double click on eclipse.exe.

It will launch the eclipse development platform.


Go to File > New > Android Application Project as shown below:




Below screen will be popped up: Enter the application name. Please note that the package name should be unique. Best practice is to have its format like “com.[site name].[app name].

Select the Minimum required SDK, Target SDK and Compile with options. This is based on your requirement. I have android 2.3.3, so I have selected it as Target SDK.

Based on the Target SDK, select Theme. Click Next.




Below screen will appear. Keep the default values and select Next.




Below screen will appear:

For this first application, Keep the default values and select Next.

You can also select the Icon for your application.




Below screen will appear:

For this first application, Select BlankActivity and select Next.

This selection depends on the Target SDK you selected before. For few SDK, some Activity will not be available.

This will basically create your application UI.




Below screen will appear:

Change the Activity name as BMIMainActivity and select Finish. This will create your first application. Coooool………..




This will be the first look and feel of the application you just have created.

By default, it will have TextView with the text set to “Hello World”.




Below screen shows the XML part of the above Layout.




Now guys, lets see the project structure. On the left bottom corner, click on the plus icon. Below screen will appear. Select the Project Explorer.




Below is the Android project structure.

Lets now understand its structure….

First folder is called “src”. It holds all the Java class files. Folder “res”, hold all the resources like the image files, sound files, Layout etc.

From below screen, you must have noticed many folders with the name “drawable-hdpi” , “drawable-ldpi”, “drawable-mdpi” etc. Here hd means high definition, ld means low definition and md means medium definition.

Folder layout have all the UI files in XML format.

Folder values, has string.xml file where you need to define any of your global variables that you will use in the layout xml files. This will reduce the hardcoding in the XML file as all the values will be defined in the single place.

AndroidManifest.xml file is the file where information about the Android application is stored.

Below series of screenshot will show the above files.



Below screen is showing the main java file which has two methods by default. Main method is “onCreate” method. This will be the starting point of the application.




Below screen is showing the string.xml file where we can define any number of the variable that will ne used in the layout xml file. Below screen is also showing the “Hello World” value that is getting displayed on the main UI. You just need to change it here and not in the layout XML file. This will make the changes/maintenance easy for the application developers.




Below screen is showing the AndroidManifest.xml file.

This file has all information required to run the Android application. I have highlighted few important lines in the below screen. First highlighted line is the complete name of the class. Second shows that it is the main class and third line tell Android OS that this is the launcher class and it will be launched whenever Android application will be executed.



This is all about the program structure.

Now lets see how to run this application.

For this Article, I will run the application on the Android Virtual device. Its just a simulator.

To run it on the simulator, we need follow few steps. Here are those steps.

Go to Windows > Android Virtual Device Manager as shown below:



Below screen will appear. Click on “New”.




Below screen will appear:

Enter AVD Name. Select any device. Make sure to select the Target Android version for which you have created the application. Keep others as default and click Ok.




It will create Android Virtual device as shown below:

Click Start to see if it is working properly.




Below screen will appear:

Change the Screen Size (in) to 6 and then click on “Launch”.




This will launch the Android Virtual device as shown below:

This shows that you have correctly setup the virtual device. You are doing great!




Now from the eclipse, go to Run > Run Configuration to configure how you are going to run your Android Application.




Below screen will appear. Double click on Android Application node on the tree at left hand side. It will create new configuration. Click on the Browse button and select your application as shown below:




Now select second tab “Target” and select the virtual device that you have created above. Finally click on Run. From next time, you just need to press Ctrl + F11 to the run the application.

Your can also select the option which will ask you to select the device before running the application.




Below is the output of your First Application on the Android Virtual device.




Happy Android Programming.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s