[How-To] Android SDK on Ubuntu 10.10

Jerry Hildenbrand

Space Cowboy
Staff member
Oct 11, 2009
5,577
2,816
113
Visit site
Hot dawg. We got our Linux forum!

Setting up the SDK is easy on Linux. It's getting the supporting tools installed that is the PITA. Here's one way to get it done. This is geared to the Ubuntu user, but it's the same method for all distros.

*newbie tip* Linux gives all folders and files permissions. By default, a user has full control over his or her home directory. ~/ is the BASH shortcut for the current users home. We'll be using it a lot.

Running as root -- yes, there is a portion of this guide that has you run commands as root. This is a bad practice, but to make the guide simpler and more universal, it's necessary in this case. Just remember, when you're running as root, you can really screw things up. Everything. Really.

Step One -- 32-bit libraries and headers
If you're using a 32 bit version of Linux, be aware that building from the AOSP tree is no longer supported after version 2.2.2. Most modern processors will run (and benefit) from using a 64-bit version of Linux, so upgrading is something worth considering.

If you are using a 64-bit version of Linux, you'll need to install the 32-bit versions of some libraries, as they aren't installed by default. If you are using Ubuntu 10.10, open your terminal and install them like so:

Code:
sudo apt-get install ia32-libs

If you're not using Ubuntu, no problem. Visit the Debian [lenny] package list and details page right here. We're using Debian's page because I'm old fashioned, and all my links are to Debian :) You can use the Ubuntu package list pages as well. In the list, find the package the Ubuntu users just installed. In this case, it's right here.

That's a list of what you need to install on your machine. Either find each in your Distro's install system, download pre-built binaries, or build them from source.

Do this each time you see a command for Ubuntu users to install software, and you can keep track of what's needed for your system.

Step Two -- Sun (Oracle) Java 6
The SDK almost works with open Java alternatives, but almost doesn't cut it. We need to install Oracle's closed source version of the Java Development Kit and Runtime Environment. Since it's closed source, it's not available by default in the Ubuntu package manager. These commands will add a repository to your apt source list that keeps the Linux version of Sun Java up to date and available, then install what's needed.

Code:
sudo add-apt-repository ppa:sun-java-community-team/sun-java6
sudo apt-get update
sudo apt-get install sun-java6-jdk

If you're using another Distro, you can get the binary from Oracle at their site right here.

Step Three -- download the SDK

Download the Android SDK for Linux right here. Open the archive, and extract the entire android-sdk-linux_86 folder into your home folder.

Now that you have it installed, you need to tell your shell where it is. Open your ~/.bashrc file and add it to your PATH. Here's a copy/paste method using nano:

Code:
nano -w ~/.bashrc
use the enter key and scroll to the very end of the file, and enter these four lines, exactly as written, but using your user name:

Code:
PATH=$PATH:/home/<user name>/android-sdk-linux_86/tools
export PATH
PATH=$PATH:/home/<user name>/android-sdk-linux_86/platform-tools
export PATH

Control+X will end nano, prompting you to save the file. Enter Y and save your .bashrc

Now you need to refresh your shell. Enter this at the prompt:
Code:
exec bash

Step four -- download the rest of the SDK
The Android SDK is modular, so you have to download the components you want/need. We're going to download them all, because it's easier to explain and one day you might want to run the emulator. At the prompt:
Code:
cd ~/android-sdk-linux_86/tools/
./android
On the left, choose Available packages.
Check the box that says Android Repository, then choose to install selected.
Choose Accept all and Install.

This take a few minutes, as it downloads everything you will ever need. If you want, you can choose to only install the tools and platform tools in your choice above.

Step five -- testing
On Ubuntu systems, adb has to run as root, or your device needs permission to communicate declared in the udev rules. You really should set up the udev rule for your phone and not run as root. In the meantime, you will need to restart adb as root each time your reboot or stop adb. Do it like so:

Code:
sudo su
<password>
cd /home/<username>/android-sdk-linux_86/platform-tools
./adb kill-server
./adb start-server
exit

Everything above is being run as root. Don't forget the exit command.

Next, make sure USB debugging is enabled on your phone, and connect it to a full speed USB port, one that's not on a hub. Sometimes hubs and front ports work fine. Sometimes they don't. Use the right ones to test, and try others later once you know it all works. After it's connected go back to the terminal:

Code:
cd ~/android-sdk-linux_86/platform-tools
./adb devices

You should see a serial number. That means it worked. Now try:

Code:
cd ~/
adb devices

You should see the same thing. This means your PATH was set-up right. And you're done. If you hit any snags, post away and we'll try to fix them.
 

igotsanevo4g

Retired Moderator
Jul 31, 2010
3,395
601
113
Visit site
Had to set up the SDK on a different ubuntu machine and im having trouble setting up the path to make life easier.

http://forum.androidcentral.com/htc.../43659-cant-get-my-evo-recognized-ubuntu.html

You helped me out awhile back in that thread, and i dont remember how i saved the path after i was done in nano. I type it in, and im not sure if its sticking or not.

My forgetfulness is killing me, im completely lost. Do i just throw in #SDK path (enter) export PATH=${PATH}:/path/to/your/sdk/tools/folder (enter) Then exit out of the terminal? What do i do next?
 
Last edited:

Jerry Hildenbrand

Space Cowboy
Staff member
Oct 11, 2009
5,577
2,816
113
Visit site
lol. Blame it on nano. It's weird if you're not used to it.

Code:
cd ~
nano -w .bashrc

changes to your home folder, and opens .bashrc (for editing, the -w is write mode)

Once it opens, you're no longer in your shell. That's nano. Scroll to the bottom of the file. Add these lines at the very end, but put your user name instead of <user name>:

Code:
PATH=$PATH:/home/<user name>/android-sdk-linux_86/tools
export PATH
PATH=$PATH:/home/<user name>/android-sdk-linux_86/platform-tools
export PATH

then hit ctrl + x (exit nano)
since you made changes, it's going to ask if you wanna keep them. Enter y to keep the changes. It will ask where to save the file, and since we opened nano with the -w switch, it will want to overwrite the original. That's what we want it to do, so just press enter to accept it.

You can edit .bashrc in ANY editor, and don't need to be root as long as you're editing your own .bashrc. You can use gEdit instead of nano if you like. I use nano for everything, so that's the way I go in tutorials.

Now you need to restart your shell to use your new $PATH. Do it like this:
Code:
exec bash

To see that the changes stuck, enter this at the prompt:
Code:
echo $PATH
you'll see a list of folders, make sure android-sdk-linux_86/platform-tools and /tools are both listed. If so, plug your phone in and try this:

Code:
sudo su
<password>
cd /home/YOUR USER NAME/android-sdk-linux_86/platform-tools
./adb kill-server
./adb start-server
exit
cd ~
adb shell

The first portion (the stuff as root) needs done to make sure the adb server is running as root. Once you set up udev, you never have to do this. After you exit out of root, you're going back home (to make sure you're not sitting in /platform-tools) and trying adb. Notice you don't use ./ unless you're in the same folder as the file you're trying to run, and in this case we aren't.

Hope this makes a little more sense :)
 

igotsanevo4g

Retired Moderator
Jul 31, 2010
3,395
601
113
Visit site
It made sense, but i think something is still wrong lol. Should it look like this -

dylan@dylan-DM174A-ABA-S5300NX-NA310:~$ cd ~
dylan@dylan-DM174A-ABA-S5300NX-NA310:~$ nano -w .bashrc
dylan@dylan-DM174A-ABA-S5300NX-NA310:~$ exec bash
dylan@dylan-DM174A-ABA-S5300NX-NA310:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/dylan/Desktop/AndroidSDK/platform-tools:/home/dylan/Desktop/AndroidSDK/tools:/home/dylan/Desktop/AndroidSDK/platform-tools
dylan@dylan-DM174A-ABA-S5300NX-NA310:~$ sudo su
root@dylan-DM174A-ABA-S5300NX-NA310:/home/dylan# cd /home/dylan/AndroidSDK/platform-tools
bash: cd: /home/dylan/AndroidSDK/platform-tools: No such file or directory
root@dylan-DM174A-ABA-S5300NX-NA310:/home/dylan#

Im guessing no :(
 

Jerry Hildenbrand

Space Cowboy
Staff member
Oct 11, 2009
5,577
2,816
113
Visit site
It made sense, but i think something is still wrong lol. Should it look like this -

dylan@dylan-DM174A-ABA-S5300NX-NA310:~$ cd ~
dylan@dylan-DM174A-ABA-S5300NX-NA310:~$ nano -w .bashrc
dylan@dylan-DM174A-ABA-S5300NX-NA310:~$ exec bash
dylan@dylan-DM174A-ABA-S5300NX-NA310:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/dylan/Desktop/AndroidSDK/platform-tools:/home/dylan/Desktop/AndroidSDK/tools:/home/dylan/Desktop/AndroidSDK/platform-tools
dylan@dylan-DM174A-ABA-S5300NX-NA310:~$ sudo su
root@dylan-DM174A-ABA-S5300NX-NA310:/home/dylan# cd /home/dylan/AndroidSDK/platform-tools
bash: cd: /home/dylan/AndroidSDK/platform-tools: No such file or directory
root@dylan-DM174A-ABA-S5300NX-NA310:/home/dylan#

Im guessing no :(

notice the path difference I highlighted above in your quote. Make sure everything is pointed to where your sdk really is.
 

igotsanevo4g

Retired Moderator
Jul 31, 2010
3,395
601
113
Visit site
Ahhh, got sloppy. Its All working now :D
So im going to have to do this
sudo su
<password>
cd /home/YOUR USER NAME/android-sdk-linux_86/platform-tools
./adb kill-server
./adb start-server

everytime i want to use adb?
 

Jerry Hildenbrand

Space Cowboy
Staff member
Oct 11, 2009
5,577
2,816
113
Visit site
Ahhh, got sloppy. Its All working now :D
So im going to have to do this
sudo su
<password>
cd /home/YOUR USER NAME/android-sdk-linux_86/platform-tools
./adb kill-server
./adb start-server

everytime i want to use adb?
cool :)

You have to do that every time the adb server dies. Any time you reboot, or do something that restarts the adb server.

http://forum.androidcentral.com/linux/57132-how-set-up-udev-rules-ubuntu-10-10-a.html

That's how you fix it on Ubuntu 10.10 so you don't have to fool with it any more.
 

Jerry Hildenbrand

Space Cowboy
Staff member
Oct 11, 2009
5,577
2,816
113
Visit site
I thought that was just making it possible so it could run without root.

If you set up the SDK as described in this post, then set up udev like described in the other post, you'll be able to plug your phone in, open the terminal and type adb shell without being root, without being in the right directory, and without using sudo.


If you skip the udev part, you need to start adb as root every time it dies.
 

ereshkigal

New member
Mar 6, 2011
0
0
0
Visit site
Hello,
I'm sorry for resurrecting old thread, but I'm really desperate..
I've got N1 and I just cannot connect it with adb. I have tried on windows 7, xp and now linux 10.10.
I've done everything that was said above but the adb cannot recognize my device. Also i tried with different programs to gain root and that was failure too. I'm starting to think that there is something wrong with the phone:confused:
 

crforbez

New member
Apr 7, 2011
2
0
0
Visit site
problems

I am trying to keep up but please be kind i am a COMPLETE NEWB. I followed the directions the best i could but right now everything works until i get to the "sudo su " part.
I type in my password and this is what i get:

[sudo] password for chris:
bash: chris: No such file or directory
bash: chris: No such file or directory
root@chris-Dell-DXP051:/home/chris#

what have i done wrong ?

when i open nano the whole file is :

PATH=$PATH:/home/<user name>/android-sdk-linux_86/tools
export PATH
PATH=$PATH:/home/<user name>/android-sdk-linux_86/platform-tools
export PATH


should it have more before that ?

thanks for even looking at this, i have no idea what to do.
 

Jerry Hildenbrand

Space Cowboy
Staff member
Oct 11, 2009
5,577
2,816
113
Visit site
when i open nano the whole file is :

PATH=$PATH:/home/<user name>/android-sdk-linux_86/tools
export PATH
PATH=$PATH:/home/<user name>/android-sdk-linux_86/platform-tools
export PATH

where it says <user name>, put in your username on the system, with out the <>. I think thats what's wrong :)

Example, on mine it would be:
PATH=$PATH:/home/gbhil/android-sdk-linux_86/tools
export PATH
PATH=$PATH:/home/gbhil/android-sdk-linux_86/platform-tools
export PATH
 

crforbez

New member
Apr 7, 2011
2
0
0
Visit site
got that

It took me a while but i had figured that out, and i also figured out that i needed to list where it is . in my case:

PATH=$PATH:/home/chris/desktop/android-sdk-linux_x86/tools

but now it seams to have a problem when i try to get into "sudo su"

I searched the issue online and i found one posting of a similar problem and what someone suggested is that the issue might be in ( cat ~/.bashrc ).....

so i type that in and there at the bottom of the list is our :

PATH=$PATH:/home/<user name>/android-sdk-linux_86/tools
export PATH
PATH=$PATH:/home/<user name>/android-sdk-linux_86/platform-tools
export PATH

with all my user name and all that.

so then i thought to my self that some where along the way i put the code there instead of in the nano where you said to put it, (it is in nano now).. but i don't know now how to remove it or if it is supposed to be there.

it does look out of place there?

thanks, thanks , thanks
 

crforbez

New member
Apr 7, 2011
2
0
0
Visit site
ahhhhh

chris@chris-Dell-DXP051:~$ cd ~/.android-sdk-linux_x86/tools/
bash: cd: /home/chris/.android-sdk-linux_x86/tools/: No such file or directory
chris@chris-Dell-DXP051:~$ cd ~/android-sdk-linux_x86/tools/
bash: cd: /home/chris/android-sdk-linux_x86/tools/: No such file or directory
chris@chris-Dell-DXP051:~$ cd ~/desktop/android-sdk-linux/tools
bash: cd: /home/chris/desktop/android-sdk-linux/tools: No such file or directory
chris@chris-Dell-DXP051:~$ ./android
bash: ./android: No such file or directory
chris@chris-Dell-DXP051:~$ exec bash
chris@chris-Dell-DXP051:~$ cd ~/android-sdk-linux_x86/tools/
bash: cd: /home/chris/android-sdk-linux_x86/tools/: No such file or directory
chris@chris-Dell-DXP051:~$ sudo su
[sudo] password for chris:
bash: chris: No such file or directory
bash: chris: No such file or directory
root@chris-Dell-DXP051:/home/chris# ^C
root@chris-Dell-DXP051:/home/chris#



guess i cant get the tools to download either. ????
 

crforbez

New member
Apr 7, 2011
2
0
0
Visit site
32 bit?

I just found out that i am running 32 bit. is that an issue because i feel like i should start from scratch at the moment?
 

Jerry Hildenbrand

Space Cowboy
Staff member
Oct 11, 2009
5,577
2,816
113
Visit site
A couple things here.

Nano is a text editor, and ~/.bashrc is a text file. You're editing ~/.bashrc using nano. Your PATH entries ahould be at the bottom of ~/.bashrc. If it makes it easier, open your home folder, press CTRL+H to view hidden files, right click on .bashrc and choose to open it with Text Editor for a more notepad like interface.

open a new terminal. At the prompt type:
Code:
which android
it will return the exact path to your tools folder if you have the path entered correctly in ~/.bashrc. If it doesn't, you will have to look and see where you extracted the SDK to, and adjust the path. If you followed the direction in post one, it will be in /home/<username>/android-sdk-linux_86/tools/

And yes, this is for 32 bit and 64 bit versions. If you're using 64 bit Ubuntu 10.10, there's an extra step in post one.
 

cmags

Well-known member
Nov 29, 2010
256
27
0
Visit site
Ok trying to do this and ran into a snag.

After installing sun-java6-jdk (sudo apt-get install sun-java6-jdk), it comes up to a configuration page with just what looks like a license agreement. There's an <Ok> at the bottom but I can't click on it since it's just text. Tried typing "Ok" and Enter, nothing. Tried ^C - nothing. ^Z backgrounded it, fg brought brings me back into the running process but didn't refresh the page. I typed clear and now all I have is a blue terminal. How do I complete the install?

Edit: Figured it out with the help of this page: http://ubuntuforums.org/showthread.php?t=601678 - a combination of <tab> and <enter> a few times because of the screwed up screen paint got me to the right combination of OK and Yes prompt acceptance.
 
Last edited:

crforbez

New member
Apr 7, 2011
2
0
0
Visit site
alright

Thank you gbhill,

I dumped my sdk and started over using the links you provided and then followed the directions to the t. everything worked perfectly.
 

porpherion

Well-known member
Mar 19, 2011
57
4
0
Visit site
Ok, sorry to resurrect, but this seems to be the most appropriate place for my issue. I just installed Ubuntu 11.04 to try and learn some android programming, and have installed the JDK, platform-tools, etc. I went to try and add the tools to my PATH, and edited the bottom od my .bashrc with this:

PATH=$PATH:/home/myusername/android-sdk-linux_x86/tools
export PATH
PATH=$PATH:/home/myusername/android-sdk-linux_x86/platform-tools
export PATH

Now, for clarification, where it says myusername, I actually have my user name, I just have a paranoia about security with stuff like that.

This is the proper path to my SDK, however, no matter what I do I get that adb is not a file or directory. I have restarted bash, tried in and out of root, and everything else I can think of (which granted, isn't much). Did 11.04 change something in the way I need to do the PATH variables, or is there just something I'm missing? I'm running 64-bit if that matters.


EDIT: Sigh, I got it. Apparently I didn't install the ia32-libs. I swear I did, but apparently not.
 
Last edited:

Forum statistics

Threads
948,841
Messages
6,940,410
Members
3,161,262
Latest member
bpbatch