Sunday, November 8, 2009

Android Development on Sprint/HTC Hero and Ubuntu

I now have a shiny new HTC Hero from Sprint which I purchased just to experiment w/Google Android.

My primary devbox is Ubuntu Intrepid. Sprint is still on Cupcake (Android platform 1.5). Still have not figured out how to "sync" between Ubuntu and Android, but development works just fine.

The Hero connects to Ubuntu Intrepid via USB and it can be mounted as a file system.

How to use the Hero as a development target.



On the Hero, select "Settings" then "Applications"

Check the "Unknown Sources" box.

Select the "Development" option.

There are three options inside Development: "USB Debugging" "Stay awake" "Allow mock locations" - select to your taste (I enable all three).


On Ubuntu, I assume you have eclipse w/the ADT plugin.
From eclipse, navigate to the build configurations. There is a dialog entitled "Android Device Chooser" - select your Hero and then run. Your application should appear on the Hero.












How to mount your Hero as a USB drive from Ubuntu.



On your devbox, create /etc/udev/rules.d/51-android.rules


gsc@cornfed:66>pwd
/etc/udev/rules.d
gsc@cornfed:67>cat 51-android.rules
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"


Connect the Hero to your devbox via USB. There should be some chatter in /var/log/messages about the new device. Something like this...


Nov 8 16:32:49 cornfed kernel: [185299.048021] usb 8-4: new high speed USB device using ehci_hcd and address 13
Nov 8 16:32:49 cornfed kernel: [185299.193667] usb 8-4: configuration #1 chosen from 1 choice
Nov 8 16:32:49 cornfed kernel: [185299.203424] scsi17 : SCSI emulation for USB Mass Storage devices
Nov 8 16:32:54 cornfed kernel: [185304.220343] scsi 17:0:0:0: Direct-Access HTC Android Phone 0100 PQ: 0 ANSI: 2
Nov 8 16:32:54 cornfed kernel: [185304.239535] sd 17:0:0:0: [sdc] Attached SCSI removable disk
Nov 8 16:32:54 cornfed kernel: [185304.239674] sd 17:0:0:0: Attached scsi generic sg3 type 0


On the Hero, pull down the status bar (i.e. push the Home symbol then touch the top of the display and drag your finger down). There should be a message saying "USB connected, select to enable". Press this. A dialog will appear warning about the mount. Select OK.

At this point you should have a freshly mounted USB filesystem. There will be more chatter in /var/log/messages (like so...)

Nov 8 16:36:44 cornfed kernel: [185533.291475] sd 17:0:0:0: [sdc] 3862528 512-byte hardware sectors (1978 MB)
Nov 8 16:36:44 cornfed kernel: [185533.294342] sd 17:0:0:0: [sdc] Write Protect is off
Nov 8 16:36:44 cornfed kernel: [185533.299343] sd 17:0:0:0: [sdc] 3862528 512-byte hardware sectors (1978 MB)
Nov 8 16:36:44 cornfed kernel: [185533.301341] sd 17:0:0:0: [sdc] Write Protect is off
Nov 8 16:36:44 cornfed kernel: [185533.302919] sdc: sdc1


Of course, df(1) will also report the filesystem


gsc@cornfed:68>df -k
Filesystem 1K-blocks Used Available Use% Mounted on
--other filesystems deleted for clarity--
/dev/sdc1 1928992 631840 1297152 33% /media/disk


At this point, you can treat this like any other mounted file system. Huzza!


gsc@cornfed:69>cd /media/disk;ls
albumthumbs DCIM HTC Sync rosie_scroll
amazonmp3 download Music Wallpaper

1 comment:

  1. Interesting blog and its so impressive, i really enjoyed to read your information, i think your blog easily to get good branding and more traffics , because every one to likes your blogs. thanks for your wonderful informative post.

    Android app developer

    ReplyDelete