Sunday, February 14, 2010

Working with Android. Chapter 1: Introduction

It's been at least a couple of weeks since my last post, and there's a lot of things I'd like to talk about. I've been studying and working on different (new) projects (some of them actually interesting).

The one I've been working on this weekend is an app to recognize handwritting for android SO mobiles and PDA's. Working with android SDK and Eclipse has been so cool that I decided to write down a few tutorials so you could also develop your own applications for android.

First: installing the development environment and the android emulator.
1. Remember this page: http://developer.android.com/. You have all the documentation / examples and references you need there. Just go and explore a little.
2. Download and install the last sdk package, which you can find here: http://developer.android.com/sdk/index.html
3. Do you have Eclipse? (better if you are familiar with it but don't worry if you aren't,  it is always a good time to start working with Eclipse). You can download it here: http://www.eclipse.org/downloads (download version 3.4 or newer).
4. Once you have SDK and Eclipse, you need to install the android plugin for Eclipse.  Run Eclipse and go to Help>Install new software>Add. Name: androidplugin Location:  https://dl-ssl.google.com/android/eclipse . Back to software view, select developer tools, then next, accept and finish. Restart Eclipse.
5. Configuring android plugin for eclipse: run Eclipse, select Window>Prefs>Android>SDK Location and fill with the SDK path. After that, apply and ok.

Second: creating an avd (android virtual device) and running the emulator
1. Go to you android sdk path/ and execute SDK Setup. Install the sdk components needed.
2. Create an android avd.  There is a graphical tool to manage/create your avds named android in /tools/.  Run android > select Virtual Devices > new. Write the name > select the android api and if you plan to work with a sdcard emulator (a .img file), then define the size of the sdcard you wish. Select Create AVD.
3. Once your avd is defined, you can start it by clicking Start>Launch. And your virtual Android will start! Easy, right?



Third: starting your own project
1. On Eclipse, select Files>New>Project>Android>Android Project. Click next.
2. Create the "hello world" app. http://developer.android.com/resources/tutorials/hello-world.html
3. On Eclipse, selct Run>Run, and you will be running your application in your virtual android device!

Some basics:
The interface (your application layout) is in /res/layout (an XML file).
The images/icons you are going to use, must be placed in res/drawable directories
Your code (java) is in /src/"package name"
Every application must have an AndroidManifest.xml file in its root directory. It has essential information about the application.  More about the manifest

And you are ready to play! Hope you have fun!

No comments:

Post a Comment