My blog on life the universe and everything…

Category Archives: Mobile Programming

How to configure HTC Desire HD for Android development on Gnu/Linux

[UPDATE 26-1-2011] I had to setup my Android phone to be used for development on another machine today, but although I followed the exact same steps that I describe in the post below (which have worked in the past),this time I was still getting

List of devices attached
???????????    insufficient permissions

when running ‘adb devices’ in the terminal. The solution it seems is to run ‘adb kill-server’ and ‘adb start-server’ as root. Then my device was sucessfuly recognized. Hope this helps anyone stuck in the same situation


I’ve just recently received my new HTC Desire HD (DHD) and naturally I’m gonna be doing all my development on it from now on. The first time I tried to install one of my apps using [adb] on the DHD I got the notorious permissions error [error: insufficient permissions for device]. Here’s a detailed step-by-step guide to fix this for the DHD (works with other Android devices too).

1. Plug in the device  🙂

2. fire up a terminal and type [lsusb] (without the square brackets)

You should see something like the following:

Bus 002 Device 003: ID 046d:c00e Logitech, Inc. M-BJ58/M-BJ69 Optical Wheel Mouse
Bus 002 Device 002: ID 046d:c316 Logitech, Inc. HID-Compliant Keyboard
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 019: ID 0bb4:0ca2 High Tech Computer Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Your list will be different depending on the usb devices that you have plugged in on your PC at the time. The one line that you should see and that is important here is the one that says “Hight Tech Computer Corp” aka HTC! The part we are interested in is higlhighted in red. Keep this in mind and move to the next step.

3. Create a file with your favorite editor under /etc/udev/rules.d called 51-android.rules (so you’ll have /etc/udev/rules.d/51-android.rules)

4. Add the following line in that file

SUBSYSTEM==”usb”, ATTRS{idVendor}==”0bb4“, ATTRS{idProduct}==”0ca2“, MODE=”0666″ OWNER=”username

Notice the red highlighted parts? Those are taken from the listing that we got when we executed [lsbusb] on the terminal. For other android devices these should be filled in accordingly. Finally replace your username in the OWNER field and save the file.

5. Make sure the file is executable by typing [chmod a+rx 51-android.rules] in the terminal

6. If you have used root priviliges to create/edit the file under /etc/udev/rules.d you might need to change the owner and the group of the file to make sure that you can execute it from your normal user account. Run the following two commands in a terminal in that case

sudo chown username 51-android.rules

sudo chgrp username 51-android.rules

7. finally restart the udev service by typing [service udev restart] or [/etc/init.d/udev restart]. Will need root privileges to do that

8. run [adb devices] on the terminal to see your device name. If you see something like this

List of devices attached
HTXXXXXXXX    device

then it worked!. If you see something like this

List of devices attached
???????????    insufficient permissions

then something is still wrong and you might want to re-iterate over the steps above

Hope this helped someone out there in androidsphere!


How to handle Android orientations in your Android app

I’ve just found an interesting article from the Android Developer’s Blog about how to properly handle orientation changes in an Android applications. Locking your app in one orientation is not enough to avoid potential problems as some new devices on the market now have a default landscape screen (e.g. Dell Streak) and even more devices have keyboards that will force an orientation change even if you have locked it programatically. So read on to the main website if you want to build better apps in the future.

G1 Android rocks!

Last week I decided to renew my carrier contract and what I got was a free Google Android phone, the G1! First few days I got playing around with it to see how it feels, and get used to the interface. I must say the team behind the UI design have done an amazing job. It’s really easy and intuitive to work with and you feel just like home very soon after you get your hands on it.

However I wanted the Android phone so I can play around with it,and when I say “play around” I don’t mean simply browsing the Internet and listening to music! I want to program the damn thing. One interesting thing I found out pretty soon while reading the forums was that there is a so called ‘root bug’ which allows anyone to get root access to the phone and do whatever he wants with it. “This is good news” I thought but a little while later I found out that Google had patched this bug with its latest updates!

No worries though! Apparently some people have done an amazing job of providing all the tools and programs to overcome the Google updates, get root access to the phone and still keep the phone updated with whatever new features Google ships in the future with its Over The Air (OTA) updates. The process of rooting your phone is not very long and difficult but it should certainly be avoided by people who don’t know exactly what thery are doing.

Anyway I rooted my phone yesterday and I am now able to do anything I want with it.
I hear some people murmuring..”well not anything, you still don’t have multitouch like the iPhone right?”

WRONG! Actually the latest rooted update out there by JesusFreke and with the help of lukehutch, zinx and ryebrye has added multitouch support for the browser and some other applications!.It turns out that the Android kernel DOES support multitouch and generates such events, but thos are being dropped by the Android Java Stack higher in the hierarchy.

I can testify that multitouch on the Browser works just fine and the future of Android looks bright and shiny! Oh, by the way the Android Market has a wealth of applications that do literaly anything you can imagine!It’s worth having a look even if you don’t own an Android, just to see what you are missing ! 🙂 (I do sound excited don’t I?).

Anyway, that’s all for now, but I am sure I will be back with more Android fun.

Next station: developer.android.com !!

P.S: Did you know you can actually install a complete Debian distribution side by side with the Android OS???? I love Freedom Software!

%d bloggers like this: