Setting up android with eclipse on linux

The purpose of this article is to get a reader started with an Android application development using an open source Android SDK on a Linux system. The main focus of the following lines will be concentrated on installation of Java based Eclipse IDE, Android SDK and Android Developer Tool (ADT) a special Eclipse plug-in on Ubuntu and Fedora Linux systems. The installation instructions will be followed by a simple Hello Android program example to test an entire installation.

Since the combination of Eclipse and Android SDK provides a powerful Android Virtual Device emulator, a reader does not need to own any Android device to get started with the Android application development.

1. Introduction

Android is a mobile operating system initially developed by Android Inc and in year 2005 it was acquired by Google Inc. In year 2007 The Open Handset Alliance was formed, which includes Google and other 33 companies. The aim of The Open Handset Alliance is to bring innovation into mobile devices and thus giving consumers a much better user experience.

At the same time, mobile application developers are given an opportunity to freely participate in Android application development using alliance’s Android Software Development Kit ( SDK ) which is released through Google’s developer website. Developers are therefore, free to develop any Android application they see fit and are free to market it to all Android mobile phone owners. This article will consist of four main sections:

2. Prerequisites

For this article, I used Ubuntu 10.04 Lucid Lynx LTS ( Long-term support ) and Fedora 14. However, all instructions below should work for any other recent Linux distribution. Therefore, requirements are very simple:

Working Linux System

Internet Connection

3. Installation

The only major difference in the whole installation procedure of Android Development environment between Ubuntu and Fedora is in installation of Eclipse ( rpm vs deb ) and Oracle Java JRE.

3.1. Eclipse IDE installation

Let us start with installation of Eclipse IDE.

3.1.1. Ubuntu

$ sudo apt-get install eclipse

3.1.2. Fedora

# yum install eclipse

3.2. Installation of Java SE Runtime Environment

In the next step, we will install the Oracle Java SE Runtime Environment. Both Linux systems Ubuntu and Fedora come with a default OpenJDK java environment. Commands below will install Oracle Java SE Runtime Environment and replace OpenJDK with Oracle JRE as a default java environment.

3.2.1. Ubuntu

Ubuntu had moved a Sun Java Runtime Environment 6 package away from a multiverse repository into proprietary repository “partner”. Therefore, if you have not done so yet you need to add partner repository to your apt sources list first. The command below might vary depends what version of Ubuntu you are running. For Ubuntu 10.04 “Lucid” enter:

NOTE: If you are running Ubuntu maverisk replace lucid with maverick in the command below !

3.2.2. Fedora

Same as Ubuntu also Fedora Linux system comes with a default OpenJDK Java fetched from a standard Fedora repository. This time however, we install Sun’s Java JRE from source. First download a Sun JRE package:

3.3. Installation of Android Developer Tool (ADT)

Android Developer Tool is a special Eclipse plug-in which contains integrated android environment for building Android application using Eclipse. The following Android Developer Tool installation steps are same for both Fedora and Ubuntu. There might be small differences between dialog boxes, but the procedure is exactly the same.

IMPORTANT :

If you are running UBUNTU 10.10 Maverick please read an appendix ( Section 8.1 ) located at the end of this document before continuing !

Start eclipse and take a note of the eclipse version number by navigating to:

Cannot complete the install because one or more required items could not be found.
Software being installed: Android Development Tools 8.0.1.v201012062107-82219
(com.android.ide.eclipse.adt.feature.group 8.0.1.v201012062107-82219)
Missing requirement: Android Development Tools 8.0.1.v201012062107-82219
(com.android.ide.eclipse.adt.feature.group 8.0.1.v201012062107-82219)
requires 'org.eclipse.gef 0.0.0' but it could not be found

Navigate to:

Help -> Install New Software -> Available Software Sites

and make sure that eclipse’s release link is present and enabled.

For HELIOS version add and enable: http://download.eclipse.org/releases/helios

For GALILEO version add and enable: http://download.eclipse.org/releases/galileo

What follows now is just a review of all items to be installed. Hit Next …

At this point we need to install platforms and optional additional plug-ins or sample codes. Start Android SDK manager:

# android-sdk-linux_86/tools/android

And select SDK Platform Android 2.3, API 9 or choose any other platform depending on your desires. You may also wish to install some Samples code and additional Third-Party add-ons.

When you have selected all packages you desire click Install Selected.

You will be prompted to Accept License. Click Accept All and then Install.

This concludes the installation part of this article.

4. Setting up Eclipse IDE with Android SDK

At this stage we need to join the Eclipse IDE with Android SDK as well as we will create an Android Virtual Device ( AVD ) to enable us conveniently test our new Android Application. To create Android Virtual Device execute a following command as a normal user. For example if you are going to develop Android Applications as a user “android” then log-in as a “android” user and execute:

$ /opt/android-sdk-linux_86/tools/android

Navigate to:

Virtual Devices -> Add

Insert a following information into:

Name: MyAndroidVirtualDevice

Target: choose any desired Android version and API level available to you from a drop down menu.

Feel free to change or add other values.

Once you click on “Create AVD” a new Android Virtual Device will be created in a following directory:

~/.android/avd

Close Android SDK manager.

The next step is to make the Eclipse IDE aware of our Android SDK installation. Start Eclipse and navigate to:

Window -> Preferences -> Android

and enter a location of your Android SDK installation into SDK Location Box and click apply:

Press OK and we are done.

5. Writing a simple Android Application

Finally we are ready to write our first Android Application.

Open Eclipse and navigate to:

File -> New -> Project -> Android -> Android Project

and insert a following information to start a new Android Project:

Press Finish.

On your left hand side you have a “Package Explorer. Use a package Explorer to navigate to:

6. Testing new android application

Now that you have saved your new project you can attempt to run it by navigating to:

Run -> Run -> Android Application -> OK

This will now start your android virtual device “MyAndroidDevice” you have created previously.

NOTE: Allow couple minutes for Android Emulator to start as this things does no happen instantly.

If your application does not start after boot you may need to navigate with your mouse to:

HOME ( house icon ) -> All Apps Launcher Icon

and select “HelloAndroid” from the list as illustrated below:

Click on your new HelloAndroid application:

7. Conclusion

So much for a Hello Android application ! Mostly this guide was about installation of an Android Development environment on a Linux Operating system and that was the hardest part. Once you have it done it is easy to write some simple android applications and see the result using Android Virtual Device emulator. The purpose of Android SDK is just to make your life as Andorid Developer easy and get you results as fast as possible.

Share — copy and redistribute the material in any medium or format
Adapt — remix, transform, and build upon the material
for any purpose, even commercially.

The licensor cannot revoke these freedoms as long as you follow the license terms.

Under the following terms:

Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.