2011-01-01

Lucid Nexus One Development

Android development is fun. It's a lot nicer than iPhone development, and although it's not as smooth as Windows Phone 7 development, you're not tied into OS or IDE. So i've recently installed Ubuntu 10.04 ( LTS ) on my netbook, mostly for performance reasons, and need to continue work on my clock widget - which hit 400,000 downloads sometime yesterday :)
There are pros and cons of Android dev'ing on Ubuntu, but the biggest one is that by default, the debug bridge ( adb ) doesn't have permissions to access the device, namely my Nexus One. Reading many online posts the suggestion is to run the adb as root, or just restart the service with sudo. Unfortunately that sucks, why?
  • You have to keep redoing it every time you start up your dev environment
  • Running a potentially insecure service as root!!!
  • If you do restart it while eclipse is running, you get some extra output in the console window
To be honest, for me the first and third are my biggest issues, i hate admin and i don't like unnecessary output in my windows, especially not in distracting red - yes i'm a psychotically pedantic developer.
So here's the proper solution:
As recommended by Google the best thing is to add a udev rules file. So,
  1. Unplug your device!
  2. Create a file as root: /etc/udev/rules.d/51-android.rules
  3. Paste this line into the file: SUBSYSTEM=="usb", SYSFS{idVendor}=="XXXX", MODE="0666"
  4. Lookup the vendor id in this table ( from the android dev site linked above ) and replace XXXX with your devices vendor id:
    ManufacturerUSB Vendor ID
    Acer0502
    Dell413c
    Foxconn0489
    Garmin-Asus091E
    HTC0bb4
    Huawei12d1
    Kyocera0482
    LG1004
    Motorola22b8
    Nvidia0955
    Pantech10A9
    Samsung04e8
    Sharp04dd
    Sony Ericsson0fce
    ZTE19D2
    If you're using a Nexus One, like myself, the vendor id is NOT in that table! At least for some reason, my vendor id registers as: 18d1
  5. Save and close the file. Plug in your dev device, and start up eclipse/adb.
That's it really!
PS: To find out the Vendor id of your random android device, run lsusb with and without the device plugged in. Do a game of spot the difference, and the first 4 digit hexadecimal number ( XXXX from the number XXXX:YYYY ) is your vendor id.

1 comment: