Installing Android Studio IDE in Ubuntu – Hello World Application

Orange Pi Development Boards

Google I/O started yesterday, and Google released an early access preview version of Android Studio, a new IDE based on IntelliJ IDEA with drag-and-drop GUI layout editor, Gradle-based build system, Lint tools, the ability to preview how apps look on different screen sizes, and more. This may eventually replace the Eclipse + ADT Plugin combination currently used, so I’ve decided to give it a try in Ubuntu 13.04 64-bit, but it’s also available for Windows and Mac OS X.

First, head over to Android Studio Installation instructions, and download Android Studio for you operating system via your Browser (You’ll have to accept an EULA), then open a terminal to extract it:


Now let’s start Android Studio:

And I did press enter to continue, but Android Studio complained about JAVA_HOME no being defined. Let’s just install Sun Oracle JAVA JDK since this is the recommended method. I’ve used the  instructions provided on Mark Loiseau blog to do so.

Download the latest Sun Oracle Java JDK (now 7.21u) from http://www.oracle.com/technetwork/java/javase/downloads/index.html. For Ubuntu 64-bit, select jdk-7u21-linux-x64.tar.gz.

Let’s install, and configure the system to use the JAVA JDK


This should be it, let’s confirm we’re using the right version:


I also had to install some extra dependencies to workaround issues with adb when running the application:


Let’s start Android Studio again with ./studio.sh

Android_Studio

Success! If you already have project based on Eclipse, Google Provides instructions to migrate your Eclipse apps to Android Studio, but today, let’s just start a New Project.

Android_Studio_New_Project

You’ll just need to provide an application name (e.g. Hello_World), and change the Package Name (replace com.example by your own) to remove a warning, and click on Next. There are several options in the wizard, but I’ve just clicked on Next several times to complete the creation of the new project. The first time will take some time since Android Studio will download, install and configure Gradle build system.

Android_Studio_Gradle_Download

Now just open the “MainActivity” as shown below to see the source code.

Android_Studio_Project_Java

Edit the code as follows (Changes highlighted in green):


I’ll use the emulator for this hello world example, so we need to configure Android Studio to use it. Click on Run->Edit Configuration, select emulator, and create a Android Virtual Device by clicking on …  (e.g. Nexus 4), and click OK.

Android_Studio_Run_Configuration

Time to run the application by pressing the Run icon (green triangle) or pressing Shift+F10. Now be a little patient, and after a while, you should see “Hello, Android” displayed in the Emulator.
Android_Studio_Hello_World

Further information is available in Android Studio Tips and Tricks page.

46
Leave a Reply

avatar
46 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
23 Comment authors
Introduction à Android et à Android Studio | lerelbolubisAndroid Studo showing :“OpenJDK shows intermittent performance and UI issues.” - TecHubhsejars[Android] Ubuntu 12.04 LTS 에서 Android Studio 설치 | antonychoi Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Tom Cubie
Guest

You are so fast 🙂 Tired after staying up night watching google i/o live.

curious_mind
Guest
curious_mind

hey nice article
i have try to install android studio on my machine ubuntu 10.10 but its giving me an error “no project to open” what to do???

hertkof
Guest
hertkof

Hi! very useful thanks but i have a ugly issue:
i got this erro:
ERROR: Cannot start Android Studio\nNo JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.
when run studio.sh.
$ java -version
java version “1.7.0_19”
OpenJDK Runtime Environment (fedora-2.3.9.3.fc18-i386)
OpenJDK Server VM (build 23.7-b01, mixed mode)
?!!
again thanks

trackback

[…] en Debian debemos descargar la versión .tgz Los que no usen Ubuntu pueden seguir este tutorialacá Los que usen Ubuntu tienen que hacer esto en la terminal sudo add-apt-repository […]

emmanuel frecon
Guest
emmanuel frecon

You have to use oracle java.

SmilingSun
Guest
SmilingSun

When it comes to this step:”and create a Android Virtual Device by clicking on … (e.g. Nexus 4), and click OK.”

I clicked the … button, but nothing happens.

Can you tell me why? Thanks so much.

SmilingSun
Guest
SmilingSun

@SmilingSun

Problem solved.
It turned out to be that /opt/android-studio/sdk/tools/android does not have enough permission.
This message showed up at the status bar of the Android Studio.

trackback

[…] Instalando e se virando no Android Studio no Ubuntu. […]

EliteTech
Guest
EliteTech

@hertkof I had to remove openjdk. Be warned though this is remove LibreOffice if you use that software.

trackback

[…] >>Installing Android Studio IDE in Ubuntu – Hello World Application Author: […]

Kate
Guest

I am also not able to install iit in my android ubantu. I am not getting any error message. It just stops itself after some time of processing.

yuechuan
Guest
yuechuan

is there a way to turn on layout preview? I looked everywhere but couldn’t seem to find it

Anwar REKIK
Guest
Anwar REKIK

Hope that the fonts rendering is better then IntelliJ IDEA cause this last one has an ugly render…

Olliexz
Guest

This was such a great help and I can honestly say I wouldn’t have managed it without this.

However, I am quite a n00b here, my drop-down for the emulated device contains no devices. How do I import device spec files or whatever it is that I need?
Thanks

Olliexz
Guest

@Olliexz
Figured it out, just the little ellipsis next to the drop-down, creating and importing the phone and saving it. *Face-palm*

Now it keeps “Waiting for ADP” and it won’t load, I keep on clicking “Wait More” but to no avail.

Olliexz
Guest
Olliexz

@cnxsoft

Dude, you are a legend.

You have my Facebook “like” and my G+ “follow”.

Joe Hannon
Guest
Joe Hannon

@Tom Cubie
thanks for the tutorial, up and running – the missing dep’s had me scratching my head for a little bit

trackback

[…] [11]http://www.cnx-software.com/2013/05/16/installing-android-studio-ide-in-ubuntu-hello-world-applicati… […]

Androidzz
Guest
Androidzz

hello friend good day!

managed to install android studio thanks to your tutorial. But I was with a doubt over the shortcut icon.

How do I create a shortcut icon to put the slash in the ubuntu?

thank you.

akbar
Guest
akbar

@akbar
Gradle:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ‘:eds:processDebugResources’.
> Cannot run program “/usr/bin/android-studio/sdk/build-tools/android-4.2.2/aapt”: error=2, No such file or directory
* Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.

Pavan Deshpande
Guest

Pavan @(pavanh)

Hi very nice tutorial , very detailed and explanatory and helpful for beginners

baocaixiong
Guest

tks!!

Rajeshwar
Guest
Rajeshwar

My build failed due to the following reason :

Gradle: Execution failed for task ‘:Hello_world:mergeDebugResources’.
> java.io.IOException: Cannot run program “/usr/share/applications/android-studio/sdk/build-tools/android-4.2.2/aapt”: error=13, Permission denied

can you help to resolve it

trackback

[…] Installing Android Studio IDE in Ubuntu – Hello World Application […]

trackback

[…] Read more: http://www.cnx-software.com/2013/05/16/installing-android-studio-ide-in-ubuntu-hello-world-applicati… […]

aje
Guest
aje

@hertkof

Hi I got similar error the first time I execute ./studio.sh after decompression.
How do you solve this problem? install sun/oracle java?

trackback

[…] installing android studio in ubuntu […]

trackback

[…] installing android studio in ubuntu […]

trackback

[…] “Flappy Tux” from Ubuntu 13.10. I’ll assume you’ve already installed OpenJDK and the Android SDK and have a working Android app development environment. I think we just need […]

trackback

[…] APIs, and bring new apps to wearables. Development can be done just like with Android in Eclipse or Android Studio, and there’s a specific emulator to try out apps in small squared or rounded display. Since […]

Fauzi
Guest

thanks bro 🙂

Jaqueline Nande
Guest
Jaqueline Nande

Hi! Nice tutorial :] Was so helpful :]

budi
Guest

I got error…Cannot launch SDK manager

trackback

[…] Not much later, luckily I also found a fix, following some of the steps of the guide here: http://www.cnx-software.com/2013/05/16/installing-android-studio-ide-in-ubuntu-hello-world-applicati… […]

hsejars
Guest
hsejars

I had 32-bit Oracle JDK6 installed in my 64-bit Ubuntu. While starting Android Studio, I got java.lang.NoClassDefFoundError: Could not initialize class sun.awt.DebugHelper

I solved this by installing the package libxtst6:i386
sudo apt-get install libxtst6:i386

trackback

[…] intermittent performance and UI issues. We recommend using the Oracle JRE/JDK." After reading this blog post and followng the tutorial, I was able to install Oracle JDK, but android studio keeps showing this […]

lubis
Guest

Rajeshwar :
My build failed due to the following reason :
Gradle: Execution failed for task ‘:Hello_world:mergeDebugResources’.
> java.io.IOException: Cannot run program “/usr/share/applications/android-studio/sdk/build-tools/android-4.2.2/aapt”: error=13, Permission denied
can you help to resolve it

chmod +x /usr/bin/java

trackback

[…] NB : l’astuce donné plus haut n’est valable que pour les Windows user, pour ceux d’entre vous qui utilise Linux, bien vouloir suivre ce lien : http://www.cnx-software.com/2013/05/16/installing-android-studio-ide-in-ubuntu-hello-world-applicati… […]