Monday 9 December 2013

Build your first Hello World Android app Tutorial 2

We continue our series on Android apps. This post will help you create your first basic  ’Hello Word’ Android app and run it.  This app will display “Hello World ! ” on your device/emulator. It is the simplest program available in any programming language. It is  traditionally used to help beginners with the most basic syntax of Android development . It is also used to verify that the environment you have set up on your system for Android development is operating correctly.
For developing an Android app on your PC or laptop, you need to set up an Android development environment on your computer. You can do that by following our first post in the series here.

Once you set up your android development environment. Follow these simple steps:

Step 1 : Open Eclipse from ADT bundle –>Eclipse folder.




While opening Eclipse, a pop-up window will ask for a workspace folder. Select the folder in your hard drive where you would like to store your Android application projects.

Step 2 : Create a new Android application project by selecting File –> New –> Android Application Project.


Step 3 : Fill in your Android project details

Give  the application a name such as ” My First Android App “.  This name will be displayed in the app menu once you install this app on an Android device or an emulator. Name the project “First App” and type in a  package name where you would like to store all your Java files.  Make sure that  you select a unique package name (example: startup.village or your firstname.lastname) and type it in lower case keys to adhere with the coding standards.


Step 4 : Locate the project folder and expand it 

Eclipse will now show the user interface of your app (Graphical Layout of activity_mail.xml) with a ” Hello World ” TextView widget right in the middle of it by default.  You can also see a newly created project folder in the package explorer window with the given project name. Expand that folder to view files.


Your Hello World App is almost ready to run but before going ahead let us take a look at the folders and files in your projects folder for a better understanding.


src  : The ‘src’ folder  or the source folder contains your package name and Java files are stored in it.
res  :  The “res” folder or the resource folder stores all your  user interface design xml files, images,sound, videos etc. that will be used in your app.
R.java  :  You can find R.java file in the gen folder. R.java is where you have access to anything you have in your resources folder.
AndroidManifest.xml : Android manifest contains essential information about the application, information the system must have before it can run any of the application’s code.


Step  5  : Run your app 

Run your app for the first time by clicking on the ” Run ” button and select Run As –> Android Application.  The Android virtual device (AVD/emulator) will automatically pop up and run the application in it.


In case you have not set up an Android device , you can do it by following our previous article. You can also connect your “USB Debugging” enabled android smartphone/tablet and install this app in it.


Please watch this space for more Android development tutorials. If you have any doubts regarding this post, you can post your queries in the comment section below and we will be happy to help you.









0 comments:

Post a Comment