• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

[How To] Install Android SDK On Ubuntu

iowabowtech

root@android:/ #
May 2, 2010
12,187
8,698
Iowa|USA
These are instructions to install the Android SDK onto Ubuntu or really any Debian distro for that matter. 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 6/29/16 for sdk revision 24.4.1]
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.1-linux.tgz

Unpack:
tar -xzvf android-sdk_r24.4.1-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-8-jdk

If you have plans to compile CM13 in particular, you may wish to also add a line to your bashrc since Ubuntu 16.x doesn't seem to play well with Java7 anymore:
sudo gedit ~/.bashrc

With your bashrc now open, add the following line to the end of the file, then save and exit...

Code:
export EXPERIMENTAL_USE_JAVA8=true


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

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:
lsusb

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:
cd
sudo gedit /etc/udev/rules.d/99-android.rules


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

Code:
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:
# Android tools
export PATH=${PATH}:~/android-sdk-linux/tools
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:
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.
 
Upvote 0
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.
 
Upvote 0
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.

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.
 
  • Like
Reactions: scotty85
Upvote 0
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...
 
Upvote 0
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.

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

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:
virtualbox-guest-x11
virtualbox-guest-dkms
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:
 C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso
open a terminal in that cd once mounted in your ubuntu virtual disk drive, and run:
Code:
 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:
 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!
 
Upvote 0
by the way, for java I used:

oracle-java6-installer

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

http://ppa.launchpad.net/webupd8team/java/ubuntu/dists/precise/main

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
 
  • Like
Reactions: teddyearp
Upvote 0
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?
 
  • Like
Reactions: jmar
Upvote 0
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.

jmar

P.S. Didn't want to start a new thread. Hope that this question is cool with you IBT.
 
Upvote 0
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.

jmar

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

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)
 
Upvote 0
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)
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?
 
Upvote 0
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?

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:
 
  • Like
Reactions: jmar
Upvote 0
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:
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. :)
 
Upvote 0
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. :)

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.
 
  • Like
Reactions: jmar
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones