RSS

Search Engine

Tuesday, November 2, 2010

Installing Google Android SDK 1.0 On Ubuntu 8.04 Desktop

Installing Google Android SDK 1.0 On Ubuntu 8.04 Desktop

Version 1.0
Author: Falko Timme
Last edited 09/24/2008

This guide explains how you can install the Google Android SDK 1.0 on an Ubuntu 8.04 desktop. With this stable release of the Android SDK, you can now develop applications for Android smartphones (like T-Mobile's G1) and offer them on the Android Market.

I do not issue any guarantee that this will work for you!

1. Preliminary Note
2. Installing Java And Eclipse
3. Installing Google Android SDK 1.0
4. Creating A First Android Application ("Hello, Android")
5. Links

1 Preliminary Note

I'm using the user name falko with the home directory /home/falko in this tutorial. Replace them with your own details where appropriate.

2 Installing Java And Eclipse

Before we can install the Android SDK, we must install Java and Eclipse (version 3.3 or 3.4 - I'm using 3.4 codename "Ganymede" here).

First, we open a terminal (Applications > Accessories > Terminal):

To install Java, we type

sudo apt-get install sun-java6-bin

(If you are on a x86_64 system, you also must install ia32-libs:

sudo apt-get install ia32-libs

)

You will be asked to accept the Java license during the installation:

The Android SDK 1.0 requires Eclipse 3.3 or 3.4. Ufortunately, the Ubuntu 8.04 repositories only have a package for Eclipse 3.2 - therefore we must install Eclipse manually.

Open a browser and go to http://www.eclipse.org/downloads/. Select one of the Java, Java EE, or RCP versions of Eclipse. I've chosen the Eclipse IDE for Java EE Developers for Linux 32bit (select Linux 64bit if you're on an x86_64 system):

Download the file to your hard drive, e.g. the desktop (/home/falko/Desktop):

To install Eclipse, we must open a terminal again. Go to the directory where you've saved the Eclipse file and uncompress it:

cd /home/falko/Desktop/
tar xvfz eclipse-jee-ganymede-linux-gtk.tar.gz

This creates a directory called eclipse.

Afterwards, you can delete the Eclipse archive file:

rm -f eclipse-jee-ganymede-linux-gtk.tar.gz

My eclipse directory is now located on my desktop (/home/falko/Desktop) - I don't want it there, so I move it to my home directory (you can leave it where it is or move it to whatever directory you prefer):

mv eclipse ~

Inside the eclipse directory, there is an executable called eclipse - that's the file we must run when we want to start Eclipse. Obviously, we don't want to do this from the command line, so we create a launcher for it.

Right-click on Applications and select Edit Menus:

Select Programming (or whatever category you want the launcher to be located in) and click on New Item:

Type in the name of the application (e.g. Eclipse) and the full path to the eclipse executable (/home/falko/eclipse/eclipse in my case) and click on OK:

Then leave the menu editor:

Now we can use the launcher to start Eclipse (Applications > Programming > Eclipse):

Eclipse is starting up...

... and asking for a workspace (you can accept the default one):

This is how Eclipse looks:

On to the Android SDK installation...

3 Installing Google Android SDK 1.0

To download the Android SDK 1.0, go to http://code.google.com/android/download.html, accept the license and click on Continue:

On the next page, select the Android SDK for Linux...

... and save it to your hard disk (e.g. on the desktop):

Now open a terminal again and go to the directory where you've saved the Android SDK and unzip it:

cd /home/falko/Desktop/
unzip android-sdk-linux_x86-1.0_r1.zip

We don't need the zip file anymore, so we can delete it:

rm -f android-sdk-linux_x86-1.0_r1.zip

We now have a directory called android-sdk-linux_x86-1.0_r1. In my case it's on my desktop - I don't want it there, so I move it to my home directory (you can as well leave it where it is):

mv android-sdk-linux_x86-1.0_r1/ ~

The android-sdk-linux_x86-1.0_r1 directory contains a subdirectory called tools (/home/falko/android-sdk-linux_x86-1.0_r1/tools in my case). We must now open ~/.bashrc and add the following line to it so that android-sdk-linux_x86-1.0_r1/tools is in our PATH:

gedit ~/.bashrc

[...]
export PATH=${PATH}:/home/falko/android-sdk-linux_x86-1.0_r1/tools
[...]

Next, we must install the Android Eclipse plugin. In Eclipse, go to Help > Software Updates...:

Go to the Available Software tab and click on Add Site...:

The Add Site window opens. Fill in https://dl-ssl.google.com/android/eclipse/ and click on OK:

Back on the Available Software tab, select Developer Tools (this should automatically check Android Development Tools and Android Editors) and click on Install...:

In the Install window, make sure that both Android Development Tools and Android Editors are checked, and click on Next >:

Click on Finish next:

The plugins are now being installed:

Eclipse must be restarted for the changes to take effect, so when you are asked if you want to restart Eclipse after the installation, you should select Yes:

After Eclipse has started again, we must update our Eclipse preferences to point to the Android SDK directory. Go to Window > Preferences:

If you see this message, click on OK and forget it:

Click on Browse...

... and select the Android SDK directory (/home/falko/android-sdk-linux_x86-1.0_r1 in my case):

Back in the Preferences window, click on Apply and then OK:

That's it, you can now use the Android SDK to create your own Android applications.

4 Creating A First Android Application ("Hello, Android")

This example is taken from http://code.google.com/android/intro/hello-android.html. It's a good test if your Android SDK is working as expected. We will create a small application that displays Hello, Android on an Android phone.

First, we create a new project (File > New > Project...):

Select Android Project and click on Next >:

Fill out the project details as follows:

Afterwards, you should see this window (navigate to HelloAndroid > src > com.android.hello > HelloAndroid.java > HelloAndroid > onCreate(Bundle) to see the source code in the source code window). Click on the Maximize icon in the upper right corner of the source code window to maximize it:

You should then see the source code in a bigger window. Modify the code so that it looks as follows:

package com.android.hello;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}

Save the file. To run the code, go to Run > Run Configurations...:

Highlight Android Application and click on the icon in the upper left corner that looks like a white sheet of paper:

The following window should come up. Fill it out as shown, click on Apply...

... and then on Run:

When you do this for the first time, the following message appears. Click on Proceed to continue:

Finally, the Android emulator comes up. It can take a while until the Android phone has started up (so please be patient), but afterwards you should see Hello, Android in the display:

Congratulations, everything is working as expected!

2 comments:

andry yudha said...

Hi, thanks for the tutorials

i wanna be android developer,,
learn about an android ,,, i like that

Anonymous said...

STEP BY STEP ANDROID TUTORIALS

VISIT:-www.androidituts.blogspot.com

Post a Comment