Recent Tweets

 
How To Run Android Apps on Ubuntu

How To Run Android Apps on Ubuntu

Last Updated: March 19, 2011 7:33 pm 3 comments

androbuntu
In order to run Android applications on Ubuntu, you will have to install the Android emulator. The Android emulator will allow you to have an environment where you can easily install and test applications without any having physical hardware.

the first thing that we want to do is make sure that we have our Ubuntu system up to date, the latest version of the Java run-time and JDK installed and our Ubuntu box configured to use the Sun versions by default.

Start by opening up a terminal window.

If you are brand new to Ubuntu you can find any application (including apps you haven’t yet installed) by using the Unity Launcher Bar

The Ubuntu Unity Task Launcher

  • Click on the Ubuntu App Button on the top.
  • Start typing the name of the application you are looking for.
  • If it appears in Installed Apps – click to run it. If it appears in available apps, install it.

Terminal will be installed. Click on it to run.


sudo apt-get update

Enter your password when the sudo command in the terminal prompts you for it.

Leave the terminal window open when the command completes.

Next run upgrade.


sudo apt-get upgrade

Now we need to get the Java JDK

You can install it from your open terminal:


sudo apt-get install sun-java6-jdk

The command above installs only the JDK. I wanted to make user everything Java was installed on my machine and up to date to avoid problems with unresolved dependencies later on so I ran this command:


sudo apt-get install sun-java6-bin sun-java6-jre
sudo sun-java6-jdk sun-java6-plugin sun-java6-source

You can run them all at once but I broke them up for formatting here on my blog.


Now we want to check and confirm that Java and the JDK / Java Compiler installed and being used are the latest. This is necessary because you can have as many different versions installed on your machine but only one will be the default.


java -version
javac -version

And you should see something like this.

Check Java Versions on UbuntuCheck Java Versions on Ubuntu


If some other version appears (like the Open JDK) then you can change the default by running this command and choosing the version that you just installed.


sudo update-alternatives --config java

Once done, we need to install the Adroid SDK.

Get it here : http://developer.android.com/sdk/

Downloading the Android SDKDownloading the Android SDK

You can decompress the files and place them in a location that makes sense for your Linux usage.

I put mine in /usr/apps/android-sdk

We also want to add the Android SDK to our shell path.

To do this, open a Nautilus instance (File Explorer) and navigate to your Home directory.

/home/YourSystemName

Then use the menu to select View->Show Hidden Files
Ubuntu Show Hiden FIlesUbuntu Show Hidden Files Find the .bashrc file and open it with the text editor of your choice.

Append the following line, changing the entry to reflect the location that you chose for the Android SDK


export PATH=${PATH}:/home/apps/android-sdk/tools

Save and close the file.

Now we can install Eclipse.

There are two ways that you can do this – but the important part is that you install “Eclipse for Java Developers“.

If you install the bare bones version of Eclipse you may find yourself in dependency hell when you try to set Eclipse up for Android.

You can download Eclipse for Java from www.eclipse.org

Download Eclipse for JavaDownload Eclipse for Java

In my case I will use Ubuntu’s synaptic package manager to install Eclipse.

You can find and run the Synaptic Package Manager using the technique referenced above.
Install Eclipse with the Synaptic Package Manager on UbuntuInstall Eclipse with the Synaptic Package Manager on Ubuntu

Note that I installed both Eclipse and Java development components.

Now we are ready to download and install the Eclipse plugin for Android Development.

  1. Start Eclipse, then select Help -> Software Updates….
  2. In the dialog that appears, select the Available Software tab.
  3. Click Add Site…
  4. Enter the Location: http://dl-ssl.google.com/android/eclipse/

Note: It’s probably better to use https for the download but I had problems in doing so.
Add the Android Developer Tools to EclipseAdd the Android Developer Tools to Eclipse

Then select the tools :
Add ADT - Select ToolsAdd ADT – Select Tools

Click next until you get to the EULA and agree to it (click yes)

Eclipse will download and install the ADT.
Installing the Android Developers Kit - ADTInstalling the Android Developers Kit – ADT

You may see a warning that the code to be downloaded is unsigned.
ADT Unsigned Security WarningADT Unsigned Security Warning

I chose to install anyway.

When everything is installed, Eclipse will prompt you to re-start Eclipse.
Restart EclipseRestart Eclipse

When you restart, Eclipse may ask you about updating the Android SDK
Eclipse Add Reference to Android SDKEclipse Add Reference to Android SDK

Eclipse will ask you a couple of permission questions – say yes.

When it’s all done we can select New -> Project
New Android Project in EclipseNew Android Project in Eclipse

Now we’re ready to start building Android Apps!

The following two tabs change content below.

Marty

Web Developer
Senior Web Developer who combines passionate coding skills, strategic vision with strong hands on leadership and enormous personal drive. I create re-usable industry standard code that is used time and time again, producing outstanding results for every project I work on! I also like Classic Motorbikes, Quad bikes, Downhill Mountain biking & Learning electronics using the Arduino.

Latest posts by Marty (see all)