Showing posts with label abd. Show all posts
Showing posts with label abd. Show all posts

Thursday, October 8, 2009

Getting adb to see my HTC Magic on 64-bit Ubuntu 9.04 / Jaunty

I wanted to get the Android app development environment up and running so I could learn how to write programs for Android and test them both in the SDK's emulator and on my HTC Magic phone.

I'd installed the Android SDK v1.6 and Eclipse 3.5 and the ADT 0.93 plugin on my 64-bit Ubuntu 9.04 system and followed all the instructions. I could happily run a program in an emulator, but I couldn't get it to see my HTC Magic Android phone via USB and actually run a program I had written on the real thing.

I gave up on Linux and tried it instead on Windows Vista, but it didn't work there, either. An "apd devices" command returned nothing unless an emulator was running.

So I did some more research and found a couple more things I could try on Linux and finally got it going. No real wizardry on my part. I managed to find a couple of good pages about the USB support in Linux with the Android 1.5 SDK from Titanium Mobile Development and Jason D Clinton. Both are linked to below. There were also some helpful comments adding to these that finally got me up and running. How much I don't know about parts of Linux will probably be obvious to people who do know, but that's just how it is. Any suggestions or refinements anyone would care to offer will be gratefully accepted.

Just to cover it off, I did try the /etc/udev/ instructions mentioned on the SDK web site. Apparently this is the future direction for authorising access to such devices, but it didn't work for me and obviously hasn't worked for at least some others.

Two pages, here and here,talking about Android SDK 1.5, provided the missing links. It appears to have someting to do with permissions and this is how you make it work.

I listed the usb devices on my system with "lsusb".



The HTC Magic is "0bb4:0c02" from High Tech Computer Corp.

This verifies the key details for identifying the phone to the system.

Then, as root (using sudo) I went to /etc/hal/fdi/policy/ *and* /etc/hal/fdi/information and created android.fdi with the following contents (courtesy of Jason Clinton):

<match key="usb_device.vendor_id" int="0x0bb4">
<match key="usb_device.product_id" int_outof="0x0c01;0x0c02">
<merge key="pda.platform" type="string">android</merge>
<append key="info.capabilities" type="strlist">access_control</append>

<merge key="access_control.file" type="copy_property">linux.device_file</merge>
<merge key="access_control.type" type="string">pda</merge>
</match>
</match>


Note the first two lines contain the first and second parts of the ID seen in the "lsusb" listing. If your phone has a different ID, you'd most likely have to amend these values to match.

Then, I performed the polkit-gnome-authorization changes listed here, and then logged out and re-booted the system. This assumes you are using the GNOME user interface on Ubuntu. Maybe I didn't have to reboot, but I wanted to be sure the contents of the android.fdi would be read and I don't know enough about how that part of the system works.

After rebooting, an "adb devices" command produced output showing I was now able to access my phone.



Even better, when I ran the "Hello Android" app, this time it actually ran on my phone, by default, and not in the emulator. Had the phone not been connected, it would have started an emulator.



Yay! A major hurdle out of the way for both app development and testing AND for getting root access to my phone and - if I choose to - loading a new ROM on it to get additional function.
Reblog this post [with Zemanta]