Debugging Your Android Application on the G1 (Or Any HTC Android Device) in Ubuntu 9.04


I have a T-Mobile G1, did I tell you? Anyways, I became interested in developing with the G1, so I am currently in the process of relearning Java (which will also come in handy Sophmore year). I was reading through the pages on Android’s Developer site when I came across a page that tells you how to debug your Android application on a physical device, rather than the emulator included in the SDK. I ran through the steps but I could not get Ubuntu to see my device. Then I figured it was some compatibility issue. After all, the latest Ubuntu version they had steps for was for Hardy. Their directions are as follows:

1. Login as root and create this file: /etc/udev/rules.d/50-
android.rules.
For Gusty/Hardy, edit the file to read:

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

For Dapper, edit the file to read:

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

2. Now execute:

chmod a+rx /etc/udev/rules.d/50-android.rules

However, in Jaunty something has changed that causes this method to no longer work. After some searching around, I put together this method:

  1. Follow the above page’s directions completely.
  2. Take the file you created, and add “SYMLINK+=”android_adb”" as on of the arguments. The file should now look like:
    SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", SYMLINK+="android_adb", MODE="0666"
  3. Instead of the filename starting with fifty, use a higher number like fifty-one:
    sudo mv /etc/udev/rules.d/50-android.rules /etc/udev/rules.d/51-android.rules
  4. Restart udev (kernel event manager) by using the command:
    sudo /etc/init.d/udev restart

Now by running the adb tool in the SDK’s tools directory with the argument ‘devices’, you should see your Android device.

The number preceding the filename is actually the priority those rules are used by udev. The higher the number, the later it is run. Something in Jaunty was changed that caused those rules to be used too late or too early.

I performed this using my G1, so in the future if you are using a device other than the G1 or the Android Developer Phone, then you can find out the 4 character code that is used in the rules file (above it is 0bb4) by using the ‘lsusb’ command in your Ubuntu console. This will list all the USB devices currently connected to your system, including your Android device. On my Ubuntu machine, the line that refers to my phone reads:

Bus 001 Device 007: ID 0bb4:0c02 High Tech Computer Corp.

As you can see, the four character code you need in your rules file is stated in the output (the first half of the device’s ID).

Have any problems, see an error in this post, or just want to praise me for this post? Just leave a comment!

9 Comments

It is so cool that you are developing for a mobile device.

Well, right now I’m learning Java, but hopefully I can actually develop on Android soon.

Thank you, it’s very useful information

[...] on the settings you need to get your Android-powered device recognized by Ubuntu 9.04 (Jaunty) [eddieringle.com/debugging-your-android-application-on-the-g1-or-any-android-device-in-ubuntu-904/]. Now that 9.10 (Karmic) is almost ready for release, you will need some modifications to that udev [...]

Thank you for posting this!

thank you for this story! had reinstalled ubuntu and was trying to recreate the udev file. the android docs are wayyy out of date and this was a huge help.

I filed a bug to get the documentation updated. http://code.google.com/p/android/issues/detail?id=6164

Yeah, went ahead and replied to that with the 9.10 post as well. :-)

There’s an impressive amount of shipment statistics relating to Android. It does sound technologically exciting but the bugs just sound like a teething problem- it happens.

Rachel

Leave a Comment