158

What all needs to be done to install Android SDK / ADT Bundle on Ubuntu?

Each of the steps in the answer was found on some different forum as I encountered obstacles getting started with my Android SDK and posted questions in appropriate forums thereafter. So I thought this would be useful in that it is a one stop solution available, in case one ever needs to re-install Ubuntu and install the Android SDK / ADT Bundle from scratch!

2

6 Answers 6

129

Actually, I think you should use Android Studio to develop android application. However, if you have your reason to use eclipse, you can follow the following guide.

Target     : Super Newbies
IDE        : Eclipse
Description: Provide a GUI method to install Android IDE using Eclipse

1. Installing Java Runtime (JDK) and Eclipse IDE

  • Search Software on Ubuntu and launch Ubuntu Software Center

    Searching

  • Search Java on Ubuntu Software Center and then install the OpenJDK Java Runtime.

    enter image description here

  • Search Eclipse on Ubuntu Software Center and then install it.

    enter image description here

  • If you have successfully installed eclipse and JDK, it will appear in the search result on your computer.

    enter image description here enter image description here

  • For the JDK, you can also press CTRL + ALT + T to open a terminal and type command java -version to check again.

    enter image description here

  • Tips : Lock the eclipse icon on launcher.

    enter image description here


2. Downloading SDK

  • Go to http://developer.android.com/sdk/index.html to download the latest version of SDK. enter image description here

  • Scroll down and click DOWNLOAD FROM OTHER PLATFORMS enter image description here

  • Click android-sdk_r22.6.2-linux.tgz under Linux 32 & 64-bit of SDK Tools Only.

    enter image description here

  • Tick I have read and agree with the above terms and conditions and click Download android-sdk_r22.6.2-linux.tgz.

    enter image description here

  • Wait for the download process.

    enter image description here


3. Preparing for Installation

  • Go to the location where you set to download the file.
  • Rigth click the file[.tgz] and select Extract Here.

    enter image description here

  • Now you can see that a file called android-sdk-linux appears as if the following.

    enter image description here

  • Enter the folder android-sdk-linux.

    enter image description here

  • Enter the folder tools and then copy the folder location.

    enter image description here

  • Press the keys CTRL + ALT + T to open a terminal and then use the following command. Where /home/casper/Downloads/android-sdk-linux/tools is the location I copied previously. You can just type cd and right click to past the location to the terminal.

        cd /home/casper/Downloads/android-sdk-linux/tools
        ./android
    

    enter image description here

  • Now the Android SDK Manager will be run.


4. Installing Packages

  • Click Install [Number] packages....

    enter image description here

  • Click Accept License and then click Install.

    enter image description here

  • Wait for the installation process.

    enter image description here

  • Finally, this message will be shown.

    enter image description here


5. Editing ".bashrc"

  • Press CTRL + ALT + T to open a new terminal and type : gedit ~/.bashrc

    enter image description here

  • Now the following text will appear.

    enter image description here

  • Add the following to the top of the entire text and then save it. (Do not close the file)

        export PATH=${PATH}:~/android-sdk-linux/tools
        export PATH=${PATH}:~/android-sdk-linux/platform-tools
    
  • Example :

    enter image description here

  • [Recommended] Move the whole file android-sdk-linux to your eclipse's workspace and under a folder that you create named Android. Moreover, you have to copy the location.

    enter image description here

  • Now back to the ".bashrc" file and the replace the '~' with the location you copied previously and then save it and close it.

    enter image description here

  • Logout and relogin your Ubuntu system.


6. Setting Up an Android Virtual Device

  • Press CTRL + ALT + T and type android avd to open the Android Virtual Device Manager.

    enter image description here

    enter image description here

  • Click New.... Set up like the following and click OK.

    enter image description here

  • Click your virtual device and then click Start....

    enter image description here

  • Click Launch.

    enter image description here

  • Launching your virtual device enter image description here


7. Installing ADT Plugin on Eclipse

  • Start Eclipse and go to Help -> Install New Software...

    enter image description here

  • Click Add....

    enter image description here

  • Type the following and then click OK.

     Name     :    ADT Plugin
     Location :    https://dl-ssl.google.com/android/eclipse/
    

    enter image description here

  • Tick the checkbox of Developer Tools and then click Next>.

    enter image description here

  • Click Next>.

    enter image description here

  • Click "I accept the..." and click Finish.

    enter image description here

  • Wait for the installation process.

    enter image description here

  • Restart eclipse.

    enter image description here

  • Click Open Preferences.

    enter image description here

  • Copy your own SDK location (The location of the file android-sdk-linux).

    enter image description here

  • Paste to the SDK Location: textbox and then click Apply and OK.

    enter image description here

  • Enjoy to create any android application with your Ubuntu.

    enter image description here

16
  • 2
    I just want to provide the easiest way with screenshots for super newbies to set up the environment. I will try you method and post it below =].
    – Casper
    May 15, 2014 at 10:18
  • 1
    Why you cannot copy the text? ~.~ I have typed all the commands. Anyway, maybe you are right.
    – Casper
    May 15, 2014 at 15:54
  • 1
    For those of you running 64-bit Ubuntu 14.10, do this sudo apt-get install lib32stdc++6. That's because you need the supporting 32-bit libraries and ia32 is no longer available. Source: dandar3.blogspot.mx/2014/03/…
    – An SO User
    Jan 25, 2015 at 18:39
  • 2
    @CasperLI Android sdk is now available on Ubuntu repo. sudo apt-get install android-sdk. Can you make a tutorial based on that? Apr 1, 2016 at 14:29
  • 1
    I think the tutorial is outdated now. i.e. ./android doesn't work anymore.
    – Sid
    Mar 31, 2019 at 7:39
105

Step 1

Check in System Settings -> Details, whether your Ubuntu is 32-bit or 64-bit


Step 2

(Using software centre or command lines) If your Ubuntu is a 32-bit OS then install libgl1-mesa-dev

In case of 64-bit OS install ia32-libs (Ubuntu 13.04 or earlier), or libgl1-mesa-dev:i386 (Ubuntu 13.10 and above)


Step 3

Install openjdk-8-jdk. If not compatible try openjdk-7-jdk, or if still not compatible openjdk-6-jdk


Step 4

Download the Android SDK command line tools here (they're located at the bottom of the page) and unzip it to a place where you can leave it as long as you need the Android SDK, /opt/ for instance.


Step 5

Check that the unzipped ADT Bundle folder (or Android SDK folder, as the case may be) have the folders tools and platform-tools. If platform-tools folder is absent, you should be able to install it from the android virtual device manager, which can be run by typing the command

   android

in the terminal. These folders contain some important commands stored. Add them to your executable path. Adding them to the path can be done as follows:

First execute gedit ~/.pam_environment. A file opens. Just add these lines to that file:

   PATH DEFAULT=${PATH}:/path/to/tools
   PATH DEFAULT=${PATH}:/path/to/platform-tools

Here you have to replace /path/to/tools and /path/to/platform-tools by the absolute paths according to where you unzipped the SDK or the ADT bundle download. Now all the commands adb, android, emulator etc can be simply executed in the terminal without giving absolute paths. That is, you will not get a "command not found" error if you gave it without its absolute path.


Step 6

Type android into the terminal and, if Step 5 was done correctly, the Android SDK Package Tool will start, where you can finish your installation.

16
  • 7
    Why would you need to modify GRUB configuration??? Oct 7, 2013 at 15:19
  • 1
    @Aneesh better to put your parameters to ~/.pam_environment instead of ~/.bashrc. Session-wide environment variables
    – catch23
    Dec 8, 2013 at 11:43
  • 1
    As the .pam_environment file is in the home directory, hence owned by the user, why does ... .pam_environment need to be run with the sudo command?
    – Wilf
    Jan 9, 2014 at 22:46
  • 1
    Good to see my answer edited. Need to keep updating from time to time, as the method could be completely different later on!
    – Karthik C
    Feb 12, 2014 at 8:19
  • 12
    Really, better to add PATH="$PATH:/path/to/tools:/path/to/platform/tools" to your .profile. .pam_environment is overwritten if you change language configuration...
    – Rmano
    Mar 6, 2014 at 14:54
6

This may seem to be a long answer, but I tried to explain every step as detailed as possible so nothing can go wrong. You can set this up in less than 5 minutes, even as a beginner.


  1. You'll need Java to use Eclipse, so install it first:

    Eclipse is an IDE. The Android ADT package is being bundled with the Eclipse IDE by default. You can also choose to use another IDE (for example NetBeans) if you prefer, but because Eclipse is the default I'll cover only Eclipse in this tutorial.

    1. Open a terminal

      Search for it in your Dash or press CTRL + ALT + T

      Terminal

    2. Execute the following commands:

      sudo apt-get update
      sudo apt-get install openjdk-7-jdk
      

      Check if you see any errors on your screen, then continue.

  2. Now download the Android ADT bundle (this is Eclipse + the Android SDK):

    1. Click here to go to the download page.
    2. Click on Download the SDK (ADT Bundle for Linux)
    3. Check I have read and agree with the above terms and conditions
    4. Select your architecture:

      How can I check this?

      • Check 32-bit if you've a 32-bit Ubuntu
      • Check 64-bit if you've a 64-bit Ubuntu
    5. Click on Download the SDK ADT Bundle for Linux
  3. Install the Android ADT bundle:

    1. Open the .zip file you've just downloaded
    2. Extract all files to a directory, for example:

      ~/ADT
      

      After extraction this directory should contain 2 other directories:

      ~/ADT/eclipse
      ~/ADT/sdk
      
  4. Add the platform-tools binaries to your $PATH:

    This is not neccesary, it'll make commands like adb accesible from a terminal.

    1. Open a terminal
    2. Execute the following command:

      nano ~/.profile
      
    3. Add the following line on top:

      PATH="$HOME/ADT/sdk/platform-tools:$PATH"
      
    4. Save the file

      You can do this by pressing CTRL + X, Y, ENTER

  5. Create a shortcut in your Dash to easily launch the ADT:

    1. Open a terminal
    2. Execute the following command

      nano ~/.local/share/applications/adt.desktop
      
    3. Paste this:

      This can be done by right cliking inside your terminal window and then click Paste.

      [Desktop Entry]
      Version=1.0
      Name=Android ADT
      Comment=Launch the Android ADT
      Exec=/home/username/ADT/eclipse/eclipse
      Icon=/home/username/ADT/eclipse/icon.xpm
      Terminal=false
      Type=Application
      Categories=Development;IDE;
      

      Note: Replace username by your username. You can get your username by executing whoami in a terminal.

    4. Save the file
    5. Execute the following command to make it executable:

      chmod +x ~/.local/share/applications/adt.desktop
      

If you've done everything right you've now succesfully installed the Android ADT. Open your Dash and search for ADT. Click on Android ADT to check if it's working!

4
  • Why do I need eclipse?
    – Braiam
    May 15, 2014 at 15:24
  • Nice one, added. May 15, 2014 at 15:40
  • @Braiam Did you get answer of your question? because i also want to know why do we need eclipse
    – d a i s y
    Mar 18, 2016 at 3:58
  • You don't need Eclipse, you just need an IDE (which Eclipse is). You can also use Android Studio if you like. It's the program you write your code in. Mar 18, 2016 at 9:04
5

You can also install adt and android-sdk from this PPA.

sudo add-apt-repository ppa:linuxgndu/adt-raring
sudo apt-get update
sudo apt-get install adt android-sdk

To complete the installation of android-sdk you need to:

sudo sh /opt/android-sdk/install-sdk

You can also install android-studio:

sudo apt-get install android-studio

Now check that the installation went as expected:

android-sdk-manager
1

There is another alternative. Integrated Development Environments (IDEs) are supposed to make programming easier, one problem with them however is that it can be difficult to install the latest version of an IDE on a Linux system (Ubuntu) if they are not in the repos. Android Studio is one such IDE.

Android Studio is the official IDE for Android application development, based on IntelliJ IDEA. On top of the capabilities you expect from IntelliJ, Android Studio offers: Flexible Gradle-based build system Build variants and multiple apk file generation Code templates to help you build common app features Rich layout editor with support for drag and drop theme editing lint tools to catch performance, usability, version compatibility, and other problems ProGuard and app-signing capabilities Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine.

Extracted from: http://developer.android.com/tools/studio/index.html

Follow this procedure:

  1. Firstly execute the following command.

sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make

  1. Then update the repo.

sudo apt-get update

  1. Now install the software:

sudo apt-get install ubuntu-make

  1. You will see all the package it will install, type ‘y’ to tell Ubuntu to proceed with the installation. Once you are done with it. Proceed with the following.

umake android

Leave the installation path as the default value;

Press enter again. You will have to agree to the license by typing ‘a’ then download starts.

Android Studio will then present you with a wizard, just keep hitting next and agree to the license. It will then proceed to download requirements for Android development, such as the latest Android SDK. Click on ‘Finish’ once the installation of required packages is complete.

1
0

CLI approach

Tested on Ubuntu 15.10, Android 22.

One the device:

Then:

sudo apt-get install ant gradle openjdk-7-jdk

cd

# Get device permissions.
# MANUAL find vendor ID on this table: http://developer.android.com/tools/device.html#VendorIds
# http://stackoverflow.com/a/5510745/895245
VENDOR_ID='054c'
UDEV_PATH='/etc/udev/rules.d/51-android.rules'
echo 'SUBSYSTEM=="usb", ATTR'"$VENDOR_ID"'=="0bb4", MODE="0666", GROUP="plugdev"' | sudo tee "$UDEV_PATH"
sudo chmod a+r "$UDEV_PATH"
sudo /etc/init.d/udev restart

wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
tar -xvf android-sdk_r24.4.1-linux.tgz

# MANUAL run the ./tools/android GUI and install the SDK versions you need 
# Better: just download EVERYTHING to save you annoyances later on.
# Yes, it takes a ton of space (50Gib+).
# http://stackoverflow.com/questions/17963508/how-to-install-android-sdk-build-tools-on-the-command-line
# The automated command line should look something like:
#API=22
#N="$(android list sdk --all |& grep 'SDK Platform Android' | grep "API $API" | cut -d- -f1)"
#android update sdk -u -a -t $N

# Studio
wget https://dl.google.com/dl/android/studio/ide-zips/1.5.1.0/android-studio-ide-141.2456560-linux.zip
unzip android-studio-ide-141.2456560-linux.zip
cd android-studio/bin
./studio.sh

# NDK
wget http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin
chmod a+x android-ndk-r10e-linux-x86_64.bin
./android-ndk-r10e-linux-x86_64.bin
mv android-ndk-r10e android-ndk

Add to your ~/.profile: TODO: which of those are actually necessary?

export ANDROID_SDK="$HOME/android-sdk"
# Present on the default build.xml generated by "android create project [...] in Android 22.
export ANDROID_HOME="$ANDROID_SDK"
export ANDROID_NDK="$HOME/android-ndk"s
export ANDROID_NDK_ROOT="$ANDROID_NDK"
# Used by https://github.com/googlesamples/android-ndk/tree/3cd41e1f5280443665ca98463c7a76e80bf0b96c/native-codec
export ANDROID_NDK_HOME="$ANDROID_NDK"
export ANDROID_ABI='armeabi-v7a'
export ANDROID_JAVA_HOME="$JAVA_HOME"
export ANDROID_STUDIO="$HOME/android-studio/"
export PATH="$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools:${ANDROID_STUDIO}/bin:${ANDROID_NDK}:${PATH}"

Logout and login. You may need:

sudo "$(which adb)" kill-server
sudo "$(which adb)" start-server

Test the installation

Get your hands on a minimal project like this one or look under $ANDROID_SDK/samples/.

If it is an Ant project (contains a build.xml file) run:

ant debug
ant installd

If it is a Gradle project (contains a gradlew file) run:

./gradlew assembleDebug
./gradlew installDebug

The app should be installed on your device.

Studio (ADT successor) can be launched with:

studio.sh

NDK samples can be found under $ANDROID_NDK/samples and you can build and install them with:

ndk-build
# Create build.xml, as per: http://stackoverflow.com/questions/5572304/how-to-build-the-android-sample-projectsusing-ant-build-xml-does-not-exist
android update project -p . -t android-22
ant clean
ant debug
ant installd

State of official Debian packages

There is currently no official Debian package.

But there is a Google Summer of Code 2015 project trying to solve that: https://www.google-melange.com/gsoc/project/details/google/gsoc2015/seamlik/5707702298738688

2
  • I'm not even sure why you logout and back in. you can just source the variables if you make the proper changes in your .bashrc file. for instance, function cat_export_vars () { cat <<- _EOF_ (export directives) _EOF_ } and then just use cat_export_vars >> .bashrc and then . .bashrc or source .bashrc which does the same thing. Better yet, this would be better as a script to set up a bare bones Android SDK.
    – user383919
    Jun 29, 2016 at 18:48
  • @jargonjunkie logout / login: sure, that would work too. I just prefer to have some variables in .profile so they are visible to things launched from dashboard. Script: this is as close as I could get, note that there are some manual steps marked which I could not automate. google-melange.com/archive/gsoc/2015/orgs/debian/projects/… is our current best hope. Jun 29, 2016 at 18:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .