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,
- Unplug your device!
- Create a file as root: /etc/udev/rules.d/51-android.rules
- Paste this line into the file: SUBSYSTEM=="usb", SYSFS{idVendor}=="XXXX", MODE="0666"
- Lookup the vendor id in this table ( from the android dev site linked above ) and replace XXXX with your devices vendor id:
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: 18d1Manufacturer USB Vendor ID Acer 0502
Dell 413c
Foxconn 0489
Garmin-Asus 091E
HTC 0bb4
Huawei 12d1
Kyocera 0482
LG 1004
Motorola 22b8
Nvidia 0955
Pantech 10A9
Samsung 04e8
Sharp 04dd
Sony Ericsson 0fce
ZTE 19D2
- 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.
Hey, man, thank you very much!
ReplyDelete