• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[HOW-TO]Set up Android SDK/ADB/Fastboot on Ubuntu Linux

Search This thread

wddglr

Senior Member
Jan 26, 2009
77
17
El Paso, TX
When I first attempted to install the SDK, I found tutorials that only had bits and pieces about the whole procedure. A lot of Google searches and hours of eye strain. I wanted to write a solid tutorial, but instead of publishing it in a personal blog, I chose to publish it here on xda-developers. This is the definite forum to come to if you are interested in Android/G1/HTC Dream development or costumization. I wrote this to make the enlarge the knowledge of this community.


!! THIS TUTORIAL IS FOR THE LATEST UBUNTU RELEASE: JAUNTY JACKALOPE 9.04 !!

!!START -------------------------------------- Optional Preparation --------------------------------------

This applies if you -

  • Are interested in installing Ubuntu for the first time.
  • Are/will be reinstalling Ubuntu from scratch.
  • Want to keep your SDK installation easy to reach.
  • Want to keep things nice and clean.
And your machine -

  • Has a second hard drive.
  • Has free space for another small partition.
This procedure will make things easier during installation of the SDK and in the long run. Hopefully you've read about partitions. If you are dualbooting, please read this first to get an idea of what you're doing.

  1. While installing Ubuntu and on the Prepare Disk Space screen (partition editor), select "Specify partitions manually (Advanced)"
  2. On the Create Partition dialog, select the following options:

    • Type for the new partition: Primary
      or Logical if you're dualbooting and know what you are doing.​
    • New partition size in megabytes: 5120MB (5GB) might work. BUT:
      It should be noted that if you ever plan on compiling kernels and/or cupcake ROM's you will NEED ubuntu8.04. You'll also need at least 10GB. :)
    • Location for the new partition: Beginning
    • Use as: Ext4 or Ext3
      Filesystem doesn't matter. (?)​
    • Mount point: /AndroidSDK
      Enter this manually
  3. Complete Ubuntu installation as usual.

-------------------------------------- Optional Preparation -------------------------------------- END!!


You will now install the SDK.




!!START -------------------------------------- Installing Android SDK --------------------------------------


Installing the SDK is the easiest of all.


  1. Download the SDK.
  2. Right-click and select Extract Here.
  3. Move the contents of the android-sdk-linux_x86-1.5_r3 directory to your desired location.
    If you followed Optional Installation, move the contents to your /AndroidSDK directory in the root of your filesystem.​
  4. Close directory window.
-------------------------------------- Installing Android SDK -------------------------------------- END!!



You will now set up your bashrc file and UDEV to recognize your HTC Device.



!!START -------------------------------------- ADB + FASTBOOT --------------------------------------

The Android Debug Bridge (adb) is one of the tools that will help you the most when you run into flashing problems or running shell commands directly from your machine. UDEV will not recognize your G1 out of the box, but we will configure it with some rules so it can connect.

We will work with /AndroidSDK as the location of your sdk. If this is not your setup, I think you're smart enough to figure it out.


Editing .bashrc file to use tools from /AndroidSDK/tools/ directory -
  1. Go to your home folder.
    Example: /home/wddglr/
  2. Press Control + H to view hidden files.
  3. Look for your .bashrc file and double click to open it with gedit.
  4. Add the following lines to the top of the file:
    Code:
    #AndroidDev PATH
    export PATH=${PATH}:/AndroidSDK/tools
    IMPORTANT NOTE
    This is the way that I have my .bashrc file setup. For those having problems with it not recognizing the adb as a command try this...
    Code:
    export PATH=$PATH:/AndroidSDK/tools
    I removed the {} around ${PATH} and it is working if I had them on it would say that it didn't recognize the command. Removed them and all works well.

Setting up UDEV to recognize HTC Device -
  1. Type the following into a terminal (Applications > Accessories > Terminal):
    Code:
    gksudo gedit /etc/udev/rules.d/51-android.rules
  2. Now add the following line to the blank file:
    Code:
    SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
  3. Click save and close.
  4. To restart udev, open up a terminal and enter:
    Code:
    sudo /etc/init.d/udev restart

Setting up fastboot -
  1. Download this fastboot binary from http://android-dls.com.
  2. Once downloaded to your desktop, right click and select Properties.
  3. Navigate to the Permissions tab and configure the following option:
    Execute: [√] Allow executing file as program
  4. Click Close.
  5. Move the fastboot bianary to your /AndroidSDK/tools/ directory.
  6. Reboot.
-------------------------------------- ADB + FASTBOOT -------------------------------------- END!!
Now you can use adb and fastboot directly from any terminal. If you chose to do the Optional Preparation, you can now save your Eclipse Workspace and your downloaded/custom ROMs/Themes in this new /AndroidSDK directory keeping things easier to reach and safe from evil disk errors or other mishaps!!! :O
If you are having problems, send me a PM. I will be happy to help.
 
Last edited:

nicholasbithell

Senior Member
May 12, 2009
97
0
Everything was going great in setting this up until I got to this part "gedit /etc/udev/rules.d/51-android.rules"

I cannot find "51-android.rules" inside of "rules.d"
Any thoughts>?
 

cynofox

Member
Jun 30, 2008
6
0
Houston
Damn you beat me to it!

I was just thinking earlier about doing this same "How-To" guide, I was surprise to see it posted just now.

Anyways, great job!
 

savethechicken

Senior Member
Jan 5, 2009
244
1
Albuquerque
Awesome tutorial for setting this up. Have been using adb/sdk on ubuntu since oct. but this would have saved me some headaches back in the first couple of weeks.

The onlything that is not clear and/or confuses me is

Setting up the udev to recognize the device.

SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

Have never used this (will now to see if it will do anything) and the only problem i have is that sometimes i have to kill-server to get it to connect correctly but i have seen this happen to almost everyone on many forums since the 9.04 came out. And even after putting this file on the computer i have had the problem.
 
Last edited:

wddglr

Senior Member
Jan 26, 2009
77
17
El Paso, TX
Awesome tutorial for setting this up. Have been using adb/sdk on ubuntu since oct. but this would have saved me some headaches back in the first couple of weeks.

The onlything that is not clear and/or confuses me is

Setting up the udev to recognize the device.

SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

Have never used this (will now to see if it will do anything) and the only problem i have is that sometimes i have to kill-server to get it to connect correctly but i have seen this happen to almost everyone on many forums since the 9.04 came out. And even after putting this file on the computer i have had the problem.

It happens to me also from time to time. especially when i reboot and want to go into adb while the device is rebooting. although that file, 51-adndroid.rules, is what helped me get adb to recognize the device. the guide on developer.android.com talked about 50-android.rules but after a few deep searches i found this: http://groups.google.com/group/android-developers/browse_thread/thread/1d3488c601243686
 

nicholasbithell

Senior Member
May 12, 2009
97
0
Okay A few questions for you....

First I fixed the whole "couldnt find the (51-android.rules) file now I am having issues with executing ADB!
When in terminal this is what I get...

"[email protected]:/home/nick# /AndroidSDK/tools/adb
bash: /AndroidSDK/tools/adb: cannot execute binary file
[email protected]:/home/nick#"

and I also noticed something different from when I start terminal the first lines now state

"bash: : command not found
[email protected]:~$"

I dont remember the first line ever being there, but I could be mistaken!

Any help would be greatly appreciated!:)

Edit: You state creating "Mount point: /AndroidSDK" During Installation, and what I did was Just place my AndroidSDK at root so it is at "/AndroidSDK". I dont know if this makes a difference.

I am actually running ubuntu 8.10 ha! I just tried to update But I keep getting errors! is there anything I can change to get this to work on ubuntu 8.10?
 
Last edited:

wddglr

Senior Member
Jan 26, 2009
77
17
El Paso, TX
First I fixed the whole "couldnt find the (51-android.rules) file now I am having issues with executing ADB!
When in terminal this is what I get...

"[email protected]:/home/nick# /AndroidSDK/tools/adb
bash: /AndroidSDK/tools/adb: cannot execute binary file
[email protected]:/home/nick#"

and I also noticed something different from when I start terminal the first lines now state

"bash: : command not found
[email protected]:~$"

Edit: You state creating "Mount point: /AndroidSDK" During Installation, and what I did was Just place my AndroidSDK at root so it is at "/AndroidSDK". I dont know if this makes a difference.

I am actually running ubuntu 8.10 ha! I just tried to update But I keep getting errors! is there anything I can change to get this to work on ubuntu 8.10?

okay, a few things -
  1. seems like your .bashrc file isn't setup right (?)
    make sure that the two lines you inserted into it are on separate line
    Code:
    #AndroidDev PATH
    export PATH=${PATH}:/AndroidSDK/tools
    because maybe export PATH=${PATH}:/AndroidSDK/tools got commented on accident if you copy pasted.
  2. When copying your SDK to the root of your filesystem, did you copy it as your own user or as root? you can use:
    Code:
    gksu nautilus
    to copy system files with complete root privileges.
  3. What exactly are you trying to update, Ubuntu or ... ? There shouldn't be a difference to get this working on 8.10, the only thing that seemed to change was the 51-android.rules file. Maybe this can help -
    • renaming it to 50-android.rules with
      Code:
      gksu nautilus
      and deleting any backups (use CTRL+H to view hidden files).
    • restarting udev using:
      Code:
      sudo /etc/init.d/udev restart

Remember this is for 9.04, not 8.10. I hope this helps.
 
Last edited:

nicholasbithell

Senior Member
May 12, 2009
97
0
okay, a few things -
  1. seems like your .bashrc file isn't setup right (?)
    make sure that the two lines you inserted into it are on separate line
    Code:
    #AndroidDev PATH
    export PATH=${PATH}:/AndroidSDK/tools
    because maybe export PATH=${PATH}:/AndroidSDK/tools got commented on accident if you copy pasted.
  2. When copying your SDK to the root of your filesystem, did you copy it as your own user or as root? you can use:
    Code:
    gksu nautilus
    to copy system files with complete root privileges.
  3. What exactly are you trying to update, Ubuntu or ... ? There shouldn't be a difference to get this working on 8.10, the only thing that seemed to change was the 51-android.rules file. Maybe this can help -
    • renaming it to 50-android.rules with
      Code:
      gksu nautilus
      and deleting any backups (use CTRL+H to view hidden files).
    • restarting udev using:
      Code:
      sudo /etc/init.d/udev restart

Remember this is for 8.10, not 9.04. I hope this helps.


Okay this is how I moved my "AndroidSDK" Folder to root....

[email protected]:~$ su
Password:
[email protected]:/home/nick# mv /home/nick/Desktop/AndroidSDK /
[email protected]:/home/nick#"

And I went to the bashrc file and it is entered in there correctly.

This is still what I get even after restarting Udev...

" bash: : command not found
[email protected]:~$ adb
bash: /AndroidSDK/tools/adb: cannot execute binary file
[email protected]:~$ su
Password:
[email protected]:/home/nick# adb
bash: adb: command not found"

Edit: This is what my .bashrc file looks like, well the top part of it anyways....

#AndroidDev PATH
export PATH=${PATH}:/AndroidSDK/tools
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
 
Last edited:

wddglr

Senior Member
Jan 26, 2009
77
17
El Paso, TX
Okay your .bashrc is setup right and it's recognizing adb and its directory.
I would say it's something to do with permissions. since you moved it under su, you are not the owner so i would say that you'd have to change the permissions of /AndroidSDK
you can do that with -
  1. Code:
    gksu nautilus
  2. Navigate to /
  3. Right click on /AndroidSDK and select Properties
  4. Click on Permissions tab
  5. Select your user account as the owner

hopefully now it will function correctly
 

nicholasbithell

Senior Member
May 12, 2009
97
0
Okay your .bashrc is setup right and it's recognizing adb and its directory.
I would say it's something to do with permissions. since you moved it under su, you are not the owner so i would say that you'd have to change the permissions of /AndroidSDK
you can do that with -
  1. Code:
    gksu nautilus
  2. Navigate to /
  3. Right click on /AndroidSDK and select Properties
  4. Click on Permissions tab
  5. Select your user account as the owner
hopefully now it will function correctly


I dont understand what this line does...

"gksu nautilus"

when i type it in it asks me for my administrative password and then after i put it in it hangs for a sec and then back to...

bash: : command not found
[email protected]:~$ gksu nautilus
[email protected]:~$
 

BlackElvis79

Senior Member
May 2, 2009
1,129
158
SoCal
Partitioning HD

First off, thank you for this thread, it's most excellent. I have a question that is slightly off topic, but not so much. I have Ubuntu 9.04 installed on my recovery partition. This partition is only 10 GB, while I have Vista on my main. I have almost 100 GB free on my main drive, and what I want to know is, if I resized my partitions to give more space to Ubuntu, how would it affect my comp? (if at all). And which OS should I be on while resizing, Ubuntu or Vista?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 12
    When I first attempted to install the SDK, I found tutorials that only had bits and pieces about the whole procedure. A lot of Google searches and hours of eye strain. I wanted to write a solid tutorial, but instead of publishing it in a personal blog, I chose to publish it here on xda-developers. This is the definite forum to come to if you are interested in Android/G1/HTC Dream development or costumization. I wrote this to make the enlarge the knowledge of this community.


    !! THIS TUTORIAL IS FOR THE LATEST UBUNTU RELEASE: JAUNTY JACKALOPE 9.04 !!

    !!START -------------------------------------- Optional Preparation --------------------------------------

    This applies if you -

    • Are interested in installing Ubuntu for the first time.
    • Are/will be reinstalling Ubuntu from scratch.
    • Want to keep your SDK installation easy to reach.
    • Want to keep things nice and clean.
    And your machine -

    • Has a second hard drive.
    • Has free space for another small partition.
    This procedure will make things easier during installation of the SDK and in the long run. Hopefully you've read about partitions. If you are dualbooting, please read this first to get an idea of what you're doing.

    1. While installing Ubuntu and on the Prepare Disk Space screen (partition editor), select "Specify partitions manually (Advanced)"
    2. On the Create Partition dialog, select the following options:

      • Type for the new partition: Primary
        or Logical if you're dualbooting and know what you are doing.​
      • New partition size in megabytes: 5120MB (5GB) might work. BUT:
        It should be noted that if you ever plan on compiling kernels and/or cupcake ROM's you will NEED ubuntu8.04. You'll also need at least 10GB. :)
      • Location for the new partition: Beginning
      • Use as: Ext4 or Ext3
        Filesystem doesn't matter. (?)​
      • Mount point: /AndroidSDK
        Enter this manually
    3. Complete Ubuntu installation as usual.

    -------------------------------------- Optional Preparation -------------------------------------- END!!


    You will now install the SDK.




    !!START -------------------------------------- Installing Android SDK --------------------------------------


    Installing the SDK is the easiest of all.


    1. Download the SDK.
    2. Right-click and select Extract Here.
    3. Move the contents of the android-sdk-linux_x86-1.5_r3 directory to your desired location.
      If you followed Optional Installation, move the contents to your /AndroidSDK directory in the root of your filesystem.​
    4. Close directory window.
    -------------------------------------- Installing Android SDK -------------------------------------- END!!



    You will now set up your bashrc file and UDEV to recognize your HTC Device.



    !!START -------------------------------------- ADB + FASTBOOT --------------------------------------

    The Android Debug Bridge (adb) is one of the tools that will help you the most when you run into flashing problems or running shell commands directly from your machine. UDEV will not recognize your G1 out of the box, but we will configure it with some rules so it can connect.

    We will work with /AndroidSDK as the location of your sdk. If this is not your setup, I think you're smart enough to figure it out.


    Editing .bashrc file to use tools from /AndroidSDK/tools/ directory -
    1. Go to your home folder.
      Example: /home/wddglr/
    2. Press Control + H to view hidden files.
    3. Look for your .bashrc file and double click to open it with gedit.
    4. Add the following lines to the top of the file:
      Code:
      #AndroidDev PATH
      export PATH=${PATH}:/AndroidSDK/tools
      IMPORTANT NOTE
      This is the way that I have my .bashrc file setup. For those having problems with it not recognizing the adb as a command try this...
      Code:
      export PATH=$PATH:/AndroidSDK/tools
      I removed the {} around ${PATH} and it is working if I had them on it would say that it didn't recognize the command. Removed them and all works well.

    Setting up UDEV to recognize HTC Device -
    1. Type the following into a terminal (Applications > Accessories > Terminal):
      Code:
      gksudo gedit /etc/udev/rules.d/51-android.rules
    2. Now add the following line to the blank file:
      Code:
      SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
    3. Click save and close.
    4. To restart udev, open up a terminal and enter:
      Code:
      sudo /etc/init.d/udev restart

    Setting up fastboot -
    1. Download this fastboot binary from http://android-dls.com.
    2. Once downloaded to your desktop, right click and select Properties.
    3. Navigate to the Permissions tab and configure the following option:
      Execute: [√] Allow executing file as program
    4. Click Close.
    5. Move the fastboot bianary to your /AndroidSDK/tools/ directory.
    6. Reboot.
    -------------------------------------- ADB + FASTBOOT -------------------------------------- END!!
    Now you can use adb and fastboot directly from any terminal. If you chose to do the Optional Preparation, you can now save your Eclipse Workspace and your downloaded/custom ROMs/Themes in this new /AndroidSDK directory keeping things easier to reach and safe from evil disk errors or other mishaps!!! :O
    If you are having problems, send me a PM. I will be happy to help.
    2
    Can anybody mirror the fastboot binary?

    Nevermind! I had a backup!

    Multiple mirrors: http://www.multiupload.com/3580DBE6YE