Welcome to the Android Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 21 of 21
Like Tree1Likes
  • 1 Post By Jerry Hildenbrand
  1. Thread Author  Thread Author    #1  

    Default [How-To] Android SDK on Ubuntu 10.10

    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.
    ಠ_ಠ
    제리
    Thanked by 2:
    basketthis likes this.
  2. #2  
    igotsanevo4g's Avatar
    Retired Moderator

    Posts
    3,558 Posts
    Global Posts
    3,549 Global Posts
    ROM
    Ice Cream Sandwich

    Default

    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-...ed-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 by igotsanevo4g; 02-04-2011 at 07:12 PM.
    Some say the glass is half empty. Some say its half full. I say, "Are you going to drink that?"
  3. Thread Author  Thread Author    #3  

    Default

    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
    ಠ_ಠ
    제리
  4. #4  
    igotsanevo4g's Avatar
    Retired Moderator

    Posts
    3,558 Posts
    Global Posts
    3,549 Global Posts
    ROM
    Ice Cream Sandwich

    Default

    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
    Some say the glass is half empty. Some say its half full. I say, "Are you going to drink that?"
  5. Thread Author  Thread Author    #5  

    Default

    Quote Originally Posted by igotsanevo4g View Post
    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.
    ಠ_ಠ
    제리
  6. #6  
    igotsanevo4g's Avatar
    Retired Moderator

    Posts
    3,558 Posts
    Global Posts
    3,549 Global Posts
    ROM
    Ice Cream Sandwich

    Default

    Ahhh, got sloppy. Its All working now
    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?
    Some say the glass is half empty. Some say its half full. I say, "Are you going to drink that?"
  7. Thread Author  Thread Author    #7  

    Default

    Quote Originally Posted by igotsanevo4g View Post
    Ahhh, got sloppy. Its All working now
    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/linu...u-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.
    ಠ_ಠ
    제리
  8. #8  
    igotsanevo4g's Avatar
    Retired Moderator

    Posts
    3,558 Posts
    Global Posts
    3,549 Global Posts
    ROM
    Ice Cream Sandwich

    Default

    Quote Originally Posted by gbhil View Post
    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/linu...u-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.
    I thought that was just making it possible so it could run without root.
    Some say the glass is half empty. Some say its half full. I say, "Are you going to drink that?"
  9. Thread Author  Thread Author    #9  

    Default

    Quote Originally Posted by igotsanevo4g View Post
    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.
    ಠ_ಠ
    제리
  10. #10  

    Default

    Looks like it's time to brush up my Linux skills and get to hacking. Almost gives me a sense of purpose.
    Thanked by:
  11. #11  

    Default

    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
  12. #12  

    Unhappy 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.
  13. Thread Author  Thread Author    #13  

    Default

    Quote Originally Posted by crforbez View Post
    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
    ಠ_ಠ
    제리
  14. #14  

    Default 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
  15. #15  

    Unhappy 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. ????
  16. #16  

    Default 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?
  17. Thread Author  Thread Author    #17  

    Default

    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.
    ಠ_ಠ
    제리
  18. #18  
    cmags's Avatar

    Posts
    264 Posts
    Global Posts
    263 Global Posts
    ROM
    CM7

    Default

    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 by cmags; 04-08-2011 at 12:00 PM. Reason: got it.. moving on.
  19. #19  

    Smile 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.
  20. #20  
    porpherion's Avatar

    Posts
    57 Posts
    Global Posts
    60 Global Posts
    ROM
    Senseless

    Default

    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 by porpherion; 04-30-2011 at 12:09 AM. Reason: Solved
  21. #21  

    Default

    I know that this is an older thread -but I just wanted to say thanks. I am just starting on ubuntu 11 and this thread and the udev thread were very helpful. Took me a while to figure out my mistakes -but I got it.

    I have a question though. I can now use adb from terminal w/o root -but when I

    adb reboot bootloader

    ...the device is no longer recognized. What do I do to fix that? Or do I need to fix anything? I mean if I need to push an ruu -I need adb to work? don't I?

    anyways thanks for all this.

Tags for this Thread

Posting Permissions