How to connect your Android phone to Ubuntu to do development, testing, installations or tethering

If you do any Android development in Ubuntu it is much better to test your applications on a real device rather than just relying on the emulator.

If you just connect the phone to the computer through USB and run adb devices you will find out that your phone is not recognized:

$ adb devices
List of devices attached
???????????? no permissions

This is easily fixable in Ubuntu. You have to add a line to a file in the /etc/udev/rules.d directory.

What line in which file depends on the manufacturer and model of the device. You can find out the Vendor ID number and Product ID number of the device by running (after you connected it via USB of course):

$ lsusb

For example, if you had a Nexus One connected you would get:

Bus 002 Device 004: ID 18d1:4e12

In this case the Vendor Id is “18d1″ and the Product ID is “4e12″. Please keep in mind that the Vendor ID for HTC changed from “0bb4″ to “18d1″. The older HTC phones like the G1 have a Vendor ID of “0bb4″.

Here is how to set up some of the major Android phones:

Step 1. Depending on your phone follow these instructions:

  • G1
    Create/edit a file in /etc/udev/rules.d called 51-android.rules:

    $ sudo gedit /etc/udev/rules.d/51-android.rules

    Add the following line to it and save it:

    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0c01″, MODE=”0666″

  • HTC Hero
    Create/edit a file in /etc/udev/rules.d called 51-android.rules:

    $ sudo gedit /etc/udev/rules.d/51-android.rules

    Add the following line to it and save it:

    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0c02″, MODE=”0666″

  • Motorola Droid
    Create/edit a file in /etc/udev/rules.d called 10-motorola-droid.rules:

    $ sudo gedit /etc/udev/rules.d/10-motorola-droid.rules

    Add the following line to it and save it:

    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”22b8″, ATTRS{idProduct} ==”41db”, MODE=”0600″

  • Nexus One
    Create/edit a file in /etc/udev/rules.d called 99-android.rules:

    $ sudo gedit /etc/udev/rules.d/99-android.rules

    Add the following line to it and save it:

    SUBSYSTEM==”usb”, ATTRS{idVendor}==”18d1″, SYMLINK+=”android_adb”, MODE=”0666″

Step 2. Restart udev:

$ sudo restart udev

Check if the device is recognized:

$ adb devices

You may need to stop and start the adb server:

$ adb kill-server
$ adb start-server

You should be good to go…

Wednesday, May 12th, 2010 Android, Eclipse, Java

5 Comments to How to connect your Android phone to Ubuntu to do development, testing, installations or tethering

  1. Thanks for the post,

    I have a nexus and for me worked writing this line:
    SUBSYSTEMS==”usb”, ATTRS{idVendor}==”22b8?, ATTRS{idProduct} ==”41db”, MODE=”0600?

    in this file:

    /etc/udev/rules.d/51-android.rules

  2. Gary on May 28th, 2010
  3. Many thanks Dimitar – my Nexus One (AT&T / Rogers Wireless) needed config as per your instructions.

    Cheers,
    Alan

  4. alan on June 9th, 2010
  5. Excellent Post. Needed to know about the different Vendor ID for the Nexus One.

    Also, I had to disconnect my phone from the USB before adb found it.

    Top One

  6. Eldog on July 11th, 2010
  7. It works. Thank you very much. My phone is Nexus One

  8. zjhlogo on July 29th, 2010
  9. I had to start the server with sudo in order for it to recognize the permissions – using Ubuntu 10.04

  10. angleet on August 1st, 2010

Leave a comment

Search

 

Archive

September 2010
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930  

Other