[How To] Install Android SDK On Ubuntu

Last Updated:

  1. iowabowtech

    iowabowtech root@android:/ #

    These are instructions to install the Android SDK onto Ubuntu. If you are only interested in adb/fastboot and do not need or want the full sdk install, please see our forum's mini-sdk option for that instead. Otherwise, read on...

    [Updated 10/16/15 for sdk revision 24.4]
    Well, I just stumbled through this and it was much harder than I remembered in the past so I thought I'd share my findings in case it helps anybody. I found none of the existing guides to be totally correct so the following is information borrowed from several sources as well as my own experiences to finally get it working:

    (All terminal commands in bold)

    Open terminal and start with this command to download:
    wget http://dl.google.com/android/android-sdk_r24.4-linux.tgz

    tar -xzvf android-sdk_r24.4-linux.tgz

    To make it work on a 64 bit machine (this was what finally made things work on my machine after a few failed previous attempts. Also note, this takes awhile, be patient):
    sudo apt-get update
    sudo apt-get install ia32-libs-multiarch

    Install jdk (if not already installed on your machine):
    sudo apt-get install openjdk-7-jdk

    Install the sdk:
    cd ~/android-sdk-linux/tools

    The sdk manager window should now pop up. Choose packages you want, of course tools and platform-tools are required as always. I'm skipping the Eclipse install, sorry if you wanted that. Just trying to help people get tools/platform tools working in this guide.

    Now plug in your phone to the usb port and type:

    This should kick out a list of plugged in devices. Most likely the last one is the phone. There were references to Samsung and Galaxy so it was pretty easy to figure out. On that same line, there is an ID number in this format...xxxx:xxxx. Write that number down for reference.

    Now a few more commands:
    sudo gedit /etc/udev/rules.d/99-android.rules

    When the rules open, go to the end and copy/paste the following:

    Code (Text):
    1. SUBSYSTEM=="usb", ATTRS{idVendor}=="####:####", SYMLINK+="android_adb", MODE="0666" GROUP="plugdev"TEST=="/var/run/ConsoleKit/database", \RUN+="udev-acl --action=$env{action} --device=$env{DEVNAME}"
    Now, replace the ####:#### in the above string of text with the number you wrote down a few steps ago. Then save and exit.

    Another command:
    sudo service udev restart

    Now check to see if you're good:
    cd ~/android-sdk-linux/platform-tools
    ./adb devices

    Watch your phone's screen at this time. If it's not on, turn it on and look for an RSA popup which authorizes your device to your PC. When you see the popup, check the box to "always allow", then hit ok.

    For those who experience the dreaded ????? No Permissions error after running the adb devices command, try this now:
    sudo ./adb kill-server
    sudo ./adb start-server
    sudo ./adb devices

    (Remove the ./ from the above commands if your path is already set)

    If you didn't experience the above problem, you should already be seeing the s/n now. If not, exit terminal, reopen and retry the above 2 commands. If all is well and you want to be able to adb/fastboot from any directory, you'll need to edit the bashrc like this:
    sudo gedit ~/.bashrc

    When the file window pops up, copy/paste the following at the end of the existing text, then save and exit:

    Code (Text):
    1. # Android tools
    2. export PATH=${PATH}:~/android-sdk-linux/tools
    3. export PATH=${PATH}:~/android-sdk-linux/platform-tools
    Now unplug phone and reboot the machine. Once booted back up, plug phone back in and from any location run:
    adb devices

    If all went well, it'll output your s/n as before but without the ./ prefix and no need to execute from the platform-tools directory. If it worked, you are all set for adb usage.

    However, I had issues with fastboot. When booting into the bootloader and running the fastboot devices command, I kept getting a "no permissions" error. The fix for this is to both edit and change permissions for /etc/udev/rules.d/51-android.rules. Rather than explain it all here, I am posting a link for this procedure that worked well for me:

    pts.blog: How to fix the adb no permissions error on Ubuntu Lucid

    After using that procedure, fastboot devices returned my device ID just fine and I had full adb & fastboot capabilities.

    Last edited: Dec 9, 2015
  2. AndroidKris

    AndroidKris Well-Known Member

    When I installed the asked on my Xubuntu machine, it literally took days. Parts and pieces didn't work right and most of what I did had no guidance or structure. I need to wipe and update my laptop, and I think I'll follow this guide for reinstall the sdk. Thanks.
  3. cowsquad

    cowsquad Member

    I did not have to update my .bashrc, nor did I have to set rules, get phone ids or anything like that. All I did was to copy adb to my bin folder, and my adb worked like a charm. So before you go to all those steps, try to simply copy adb to the bin folder.
    Thanks for this guide though. I am just adding my 2 cents :)
    scary alien likes this.
  4. iowabowtech

    iowabowtech root@android:/ #

    Good to know. I'll definitely give that a shot next time. And that allows you to run adb and fastboot from anywhere along with automatic device recognition?
  5. cowsquad

    cowsquad Member

    Yes, well on my case it does :)
  6. iowabowtech

    iowabowtech root@android:/ #

    Due to technical difficulties when trying to upgrade 12.04 to 12.10, I ended up wiping clean and installing 12.10 from scratch today. I didn't have any luck with the adb to /bin method mentioned above but I did have great luck using the same method I posted in the OP. I updated the thread just slightly to include reference to revision 21 (previously r20).

    Changing thread title to reflect that this is working on both 12.04 and 12.10.
  7. iowabowtech

    iowabowtech root@android:/ #

    Updated OP for newest SDK version.
  8. dhworph

    dhworph Well-Known Member

    I have Ubuntu 12.04 running inside VirtualBox with Windows 7 Pro x64 as the host. It works great with adb (except doesn't like usb3, but usb2 works). I am able to compile AOSP this way, and it works great with adroid sdk. However, the usb connection seems a bit slower, probably something to do with it being a virtual machine. Also, I can't get the virtual android device to work... I think that is definitely a problem with being on a virtual machine.

    VirtualBox is a great way if you want to dabble in ubuntu but don't want to commit to dual boot or worry about messing up your windows install.
  9. iowabowtech

    iowabowtech root@android:/ #

    Cool. Yeah I am actually dual booting at this time. Only because my next elder machine is older than the hills and I'm too cheap to buy a dedicated machine for my Linux install. :D

    In a perfect world tho, I would definitely have a 2 machine setup with a kvm switch and dual monitors. I mean while we're dreaming, may as well do it right.
    scotty85 likes this.
  10. dhworph

    dhworph Well-Known Member

    I was dual boot with my xp machine, but that was 6 yrs old, so I just upgraded... got good enough hardware now for a virtual machine! Quad core i7 w/ multithreading, and 16GB ram. I can compile AOSP in less than an hour! Now I just have to learn java, so I can edit the code... lol.

    if only drag-n-drop and copy/paste worked across the vm, it would be that much more awesome... I was skeptical about the new ubuntu design, but I am pretty stoked on it now and win 7 (they are very similar in functionality in my opinion). So much easier to navigate the system...
  11. Eproffittibeta

    Eproffittibeta New Member

    This website will help you tremendously (sorry, new, not allowed to put links yet) virtualboxes.org/doc/installing-guest-additions-on-ubuntu/
    dhworph likes this.
  12. dhworph

    dhworph Well-Known Member

    Sorry if this is a bit of a derail for this thread, but the instructions for getting android sdk installed in Ubuntu should work exactly the same if it is running inside a VirtualBox. I have a guest Ubuntu 12.04 LTS x64 installed inside VirtualBox 4.2.6 r82870 inside my host Windows 7 pro x64. I am able to compile working AOSP on it, perform adb/fastboot commands, use the android kitchen, and do all manner of android tinkerings. What follows is what I did to get shared folders and shared clipboard and drag-n-drop (mostly) working.

    For me those instructions were incomplete as I already had the guest additions installed, but for some reason, they were different than what came in the virtualbox iso (I installed them from the machine menu).

    I uninstalled via synaptic package manager:
    Code (Text):
    1. virtualbox-guest-x11
    2. virtualbox-guest-dkms
    3. virtualbox-guest-utils
    After some Googling, I uninstall those 3 guest addition packages form synaptic package manager, and then installed the guest additions from the virtualbox iso:

    Mount the iso (for me it was VBoxGuestAdditions.iso) in the virtual machine cd drive
    From VBox menu: Devices > CD/DVD Device > Choose a Virtual CD/DVD disk file... for me it was:
    Code (Text):
    1.  C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso
    open a terminal in that cd once mounted in your ubuntu virtual disk drive, and run:
    Code (Text):
    1.  sudo ./VBoxLinuxAdditions.run
    This did not result in seeing any new packages installed in synaptic, so I suspect the iso packages are not in any of my synced repositories. I don't think this actually changed my clipboard/drag-n-drop behavior, but it works almost perfectly, except that I cannot drag-n-drop from my guest ubuntu to my Windows host.

    However, this did send me on a research spree getting my shared folder working. It involved making sure my ubuntu user was in the usergroup "vboxsf". I had to manually add that group (cant remember if root is required to add the user to the appropriate group).

    Code (Text):
    1.  usermod -a -G vboxsf <username>
    As when I set VirtualBox to automount the shared folder, it is always mounted as root and group vboxsf, and I wasn't able to change those permissions, as they are always reset with each automount.

    I've learned so much by messing with my ubuntu vm... hope someone finds this info useful!
    iowabowtech and teddyearp like this.
  13. dhworph

    dhworph Well-Known Member

    by the way, for java I used:


    from the package repository (had to add it manually):


    Note that compiling AOSP requires java 6, it wont work with java 7.

    Edit: seems I have all of oracle-java6-installer, oracle-java7-installer, openjdk-6-jdk installed, however, "java -version" shows 1.6.0_39, which is from oracle-java6-installer (which has an upgrade to version 42 currently). However, I am scared to to upgrading/removing as I worry it might affect my system stability... I got AOSP working and don't wanna mess with it! :p
    teddyearp likes this.
  14. iowabowtech

    iowabowtech root@android:/ #

    Not at all, thanks for adding it. :)
  15. AndyOpie150

    AndyOpie150 <strong> <a href="http://androidforums.com/optimus Contributor

    Just thought I'd thank you for this guide. I've only did this once in late 2011-early 2012? and forgot.

    Changed to Xubuntu from Super OS 11.10 (my old system is pleased).
    Google gave me your tutorial.

    One thing I thought I'd mention for those new to Linux: To keep from getting "permission denied" you need to right click the adb.exe then select properties. Then select the permissions tab. Check the box that allows the file to be run as a program.

    I do this for all .exe's in the SDK folder.

    PS: Do you know how to set up APK MultiTool on Linux?
    jmar likes this.
  16. dhworph

    dhworph Well-Known Member

    I think at least most of the apk-multitool utilities can be run from the shell in linux since they are just jars (apktool.jar, smali.jar, baksmali.jar).
  17. AndyOpie150

    AndyOpie150 <strong> <a href="http://androidforums.com/optimus Contributor

    Probably so. I'm just a perfectionist (OCD). Got to have everything running just right.

    EDIT: Just noticed my post count. Who Da Thunk It. Two years ago I was just looking for a little help to fix my phone and landed here at Android Forums.
  18. AndyOpie150

    AndyOpie150 <strong> <a href="http://androidforums.com/optimus Contributor

    dhworph likes this.
  19. dhworph

    dhworph Well-Known Member

    AndyOpie150 likes this.
  20. jmar

    jmar Nexican VIP Member

    Could someone chime in and help me get my Ubuntu 12.10 install to mount micro SD card storage using a multicard reader. I've Googled it and found a few things but nothing I've tried works. I don't own any devices with micro SD slots soi this is my only method. Thanks in advance.


    P.S. Didn't want to start a new thread. Hope that this question is cool with you IBT.
  21. iowabowtech

    iowabowtech root@android:/ #

    No problem jmar. I don't have a sure answer for you because my multi card reader just works with ubuntu 12.10. I didn't do anything special. If you're not so lucky, I can only guess you'd need to create a udev rule for it. You checked out anything like this yet?

    Update on writing udev rules for flash card readers (Shallow Thoughts)
  22. jmar

    jmar Nexican VIP Member

    I looked at this and I understood it. But my SD card reader's node cannot be found so I can't get past the first couple steps. I clicked on some other links with no luck. Maybe I need to get a new card reader. Any suggestions?
  23. iowabowtech

    iowabowtech root@android:/ #

    If it doesn't show up at all, I'm not sure what to say man. You might try the Linux thread in the Lounge. There's some gurus in there that may have an idea. Wish I could have been more help. :eek:
    jmar likes this.
  24. jmar

    jmar Nexican VIP Member

    Hey there IBT: just so I understand, when you plug in you card reader via USB, it automatically mounts? If so, which one do you have so I can maybe pick one up today. :)
  25. iowabowtech

    iowabowtech root@android:/ #

    Yeah, it auto mounts. It's a Digital Concepts model CR-70 but I have to warn you, it's several years old. I somewhat doubt this model is available anymore but you never know I guess.
    jmar likes this.

Share This Page