Wednesday, 22 May 2013

Creating First android project in eclipse

Creating your first android project in eclipse :)

Hope you have configured your java,eclipse and android properly before continuing further.
If Not check these posts about configuring java in your system

Setting up java in unix or
Setting up java in windows

and these for configuring android in your system

Setting up android in ubuntu/unix/linux or
Setting up  android in windows
Once you have done with above things follow these steps to create your first android project.

Am using latest adt bundle of version 21(All version are same with minor addition so no need to worry about versions)


  1.  Open your eclipse (configured for android or from adt bundle as said in my previous post)

  2.  Go to File menu -> select New -> Android Application Project

  3.  Fill up application name as you want ( this will be your app name )

  4.  Other things will be filled by default by eclipse so no worry just click Next Next

Finally you will see finish button, click on it, that's it! your first android project is created :)
Now the question is,,  how to run this? what is the structure of the project ?

Well, on the left side you can see Package explorer (if not go to Windows menu -> show view ->Package explorer). Expand the package (it will be your application name which you entered) you get many folders underneath, Expand src folder, under that will be your complete package(all class files every thing), The class which extends Activity is the one which runs when you run your project.

Now the other main thing to see is, your layout file which you can find under res/layout/xxx. xml file This is the file which is used to configure your app's layout.

Last but not the least Android Manifest.xml which is at the end in your package list, it is used to set
permissions, tell which activity executes first etc :)

So far you learnt basic layout of android

Now we will see how to run the android project?
To run the application we need an android phone.. o.O android phone?? yes!!
how will we know the errors, trace logs debug??

yes you are right we should not directly run apps on phones until tested properly so now?

Create your own emulator.. follow these steps

  1. Goto windows-> Android Virtual Device Manager -> click on new

  2. Fill the values as in the figure


  3. Now click create thats all your emulator is created!!!

  4. Now we need to deploy the application into this emulator

  5. Goto project->click run (nd make sure under run the build automatically is selected)

  6. Now eclipse will deploy your application into the emulator and starts the application for you

                                        wow!!! you created your first android project congrats !!!


Leave your doubts or suggestions in comments section..

No comments:

Post a Comment