Android Debug Bridge on HTC Desire

Illustration

Debugging Android programs on real device is easy. You just need to follow guide and everything will work. That is theory at least.

All instructions worked just fine up-to point where USB driver had to be installed. Dreadful “Driver not found” was all I was getting. Problem was obvious. My HTC Desire was just too new to be included in driver pack.

However, I had a hunch. “USB Driver for Windows, Revision 3” that was available to me was one that included support for Nexus One. Since Desire seems pretty close to it, I wanted system to use Nexus drivers anyhow.

First thing to do is right-click on My Computer, select Manage and go to Device Management. There you will see ADB device with yellow question mark. Right-click on that device and select properties. Under tab Details there is one combo box with properties. There we need to see “Hardware Ids”.

In case of HTC Desire hardware IDs in question were “USB\VID_0BB4&PID_0C87&REV_0100&MI_01” and “USB\VID_0BB4&PID_0C87&MI_01”. In “android_winusb.inf” file I just copied two entries for Google Nexus (“%SingleAdbInterface%” and “%CompositeAdbInterface%”) and replaced their hardware IDs with hardware IDs for Desire (with slight trimming). Changes are highlighted:

...
;Google NexusOne
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_0D02
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_0D02&MI_01
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E11
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E12&MI_01
;
;HTC Desire
%SingleAdbInterface%        = USB_Install, USB\VID_0BB4&PID_0C87
%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C87&MI_01
[USB_Install]
...

And voilà, we have our driver ready.

P.S. While I talk about HTC Desire here, there is no reason why same method would not work for any other Android phone, providing that it is compatible (on USB communication level) with Nexus.

[2010-06-17: At least in case of Windows 7 and it’s “No driver found” error, it is enough to add only %CompositeAdbInterface%. I haven’t tested on other operating systems but I think that %SingleAdbInterface% is not used at all.]

Microsoft Kinect

Illustration

I wrote some time ago about Project Natal. It seemed like great technology but I heard no news about commercial release for quite a while.

Yesterday (2010-06-13) it was presented at Electronic Entertainment Expo in Los Angeles (E3) under it’s new name - Microsoft Kinect. Somebody ought to shoot marketing department since developer code names are pretty much always better than final product name.

Although release date was not specified, technology seems to be quite ready and I do hope that it will be released this year. Even with it’s new name it remains best thing to have in living room and, for me, single reason why I might buy XBox.

Get Application's Icon

When I was building “About” dialog for my applications, I wanted it to be as reusable as possible. That meant that all data should be retrieved while program is running. Only thing that I could not discover within .NET code was application’s icon.

Windows API came to rescue. In short we just load our own assembly for purpose of extracting one icon resource. That gives us “good old” pointer which can be used to create bitmap.

IntPtr hLibrary = NativeMethods.LoadLibrary(Assembly.GetEntryAssembly().Location);
if (!hLibrary.Equals(IntPtr.Zero)) {
    IntPtr hIcon = NativeMethods.LoadIcon(hLibrary, "#32512");
    if (!hIcon.Equals(IntPtr.Zero)) {
        Bitmap bitmap = Icon.FromHandle(hIcon).ToBitmap();
        if (bitmap != null) { return bitmap; }
    }
}

Probably most curious thing is “#32512” string. This is resource identifier that goes way back into non-CLR past (also-known-as IDI_APPLICATION constant) and it is not only one that can be used.

Here is full sample.

What Is Happening to Me?

Illustration

Few days ago I wrote instructions for setting-up Android development environment. Since I am mostly known as Windows developer this caused lot of questions in my neighborhood. Here are answers to most common ones and some observations of mine.

1. Yes, I am still C# developer at heart.

2. I still love Windows Mobile. This goes for 6.5. As far as Windows Mobile 7 is concerned, I have my reservations (this is drastic change after all) but it is really hard to comment anything at this time. Most of known limitations and features of that platform are subject to change by the time of launch. Anyhow most of things that bother me are just political decision (e.g. multitasking) and not a real limitation.

3. I do not consider my work in Android as betrayal of my love. While I love Visual Studio and what it does offer, I think that trying other environments can only lead to good things.

4. My phone ratio is 2:1 in favor of Windows Mobile (HP iPAQ 514, HTC S740 and HTC Desire).

5. Exchange ActiveSync is best protocol there is. I am not sure how good it was for Microsoft to allow Google and others to use it in their products but from customer side I must confess it is great decision. It allows all my phones to share same data regardless of their underlying platform and everything gets synchronized by “it-self”.

6. Both Windows Mobile and Android share same hate for letters Đ and đ (latin capital/small letter D with stroke). While I can synchronize existing contacts with this letter, neither of these platforms will allow me to enter this letter via keyboard. When letter is part of your alphabet it gets annoying fast.

7. Yes, I will probably make some comparison of development experience between these platforms in future.