This is a basic tutorial with simple example on installing Android sdk and setting up development environment for Ubuntu machine. If you are using windows machine for development, then instructions may vary.

Install java

If the development machine already has java SDK, then you can escape this step(JRE alone is not suffcient).

  1. If your development machine is 64bit, you need to install the ia32-libs package.
    sudo apt-get install ia32-libs
  2. Now install java by executing the command on the terminal given below.
    sudo apt-get install sun-java6-jdk  

Install Eclipse

Android SDK recommends to use Eclipse 3.6.2(Helios). You should download the Java or RCP version of eclipse from this link.
For installing the eclipse present in Ubuntu distribution, execute the following command on terminal.

sudo apt-get install eclipse

If you have downloaded from the Eclipse website then unzip eclipse-x-y-z.tar.gz using the following command.

tar -zxvf eclipse-x-y-z.tar.gz

Whenever you need eclipse, double click the eclipse executable file in Eclipse/bin directory.

Install Android SDK

Download the Android SDK from here. If you have development platform other than Ubuntu, click the other platforms link. For window platform, it is quite easy, just download the installer and install in your machine. For Ubuntu, download the SDK and  extract it using following command.

tar -zxvf android-sdk_r20.0.3-linux.tgz

The extracted Android folder contains some basic tools. It doesn’t contain the android or third party libraries. To get the Android libraries. you need to execute the following command in android-sdk-linux/tools directory

chmod +x android   #This makes android script executable.
./android sdk      #This shows the SDK manager.

The following window will appear. Select the required SDK to install and click install packages button. The latest SDK version is 16(Adnroid Jelly-Bean).

If you are interested in the android script and the various options available, run the following command:

./android --help  #lists all the options available with this script.

Install ADT plugin in Eclipse

  1. Start Eclipse
  2. Menu help > Install New Software
  3. You will notice the following dialog
    Install ADT plugin Eclipse
  4. Click ADD button. In name field enter “ADT plugin” and in URL field enter “https://dl-ssl.google.com/android/eclipse/”
    Add plugin repository
  5. From the list of packages, select Developer Tools and click next .
    Install ADT plugin eclipse 2
  6. You will see the list of tools to download. select the tools and click next.
  7. Read and accept the license and click Finish button (for troubleshooting installation issue, find solution here).
  8. Once the installation is done , restart the Eclipse.
  9. Go to menu window>preference>Android (select from left panel) to configure the ADT plugin. From the main panel, click the browse button and select the SDK location (i.e android-sdk-linux) and click Apply and then OK button.

Create Android Virtual Device(AVD)

We are now not just one step behind the coding in Android. Once the AVD is created, then we can start developing the application and testing on AVD. It’s really easy to create AVD in few simple steps.

  1. Click the Android Virtual Device Manager icon in eclipse tool bar as shown below.
    Android Virtual Device Manager Eclipse
  2. You will see Android Virtual Device Manager. Click New button.
    Android virtual Device Manager Dialog
  3. This dialog window asks various configurations of the virtual device. Provide suitable name in the Name field, fill the target field with the Android SDK version, as you can see API level 16 has been selected(Android Jelly Bean). If you require SD support, then fill the size field.
    Create new Android virtual device eclipse

    Once done, click the Create AVD button

  4. Once the AVD is created, select the AVD and click start button on AVD manager window. AVD takes time to get initialized and launched. You have to be patient.
    Android AVD example

    If you get libGL.so error while launching the AVD, then check out this post.

Create Android Hello world project

  • In Eclipse, File > New > Android Application project, fill the fields as shown below and then click next. Make sure that the minimum selected SDK version is equal or higher than the AVD API version.
    Android Helloworld example application.
  • Select the BlankActivity and click next button.
    New Android Hellowold application
  • Don’t change the default value and click next.
    New Android Helloworld application 3
  • You will notice that ADT plugin has created the following directory structure. src folder contains the source code, where as res folder contains the resources of the application which include layout file, icons, menu, value etc. Also, there is an AndroidManifest file which defines the property of the application(a kind of configuration file).
    Android Eclipse project explorer

    Now click the run on eclipse toolbar.

  • If the current project is launched for the first time, then eclipse shows the Run As dialog box as given below. Select Android application from the list and click OK.

    This will launch the AVD if it has not already been launched and will show  the Activity window.

  • On pressing the home button, you can see the application icon as shown below and once the icon is clicked, the application gets launched and shows the following screen.
    Android application list Android HelloWorld Application

With this, you have completed Android helloWolrd!! application. You can play around with the code and explore the various resources files . Check this page for more Android Tutorial.

Please feel free to comment on the post or website. Thanks and happy Android coding!!!

,
Trackback

only 1 comment untill now

  1. Code4ReferenceAndroid Hello world!!! example…

    Thank you for submitting this cool story

Add your comment now