Thursday, December 27, 2012

I Pour the App I Built onto My Own, Android Phone

Yesterday, I built an app that runs on my Beagleboard. I should be able to put the same app onto my phone, right? Yes, this is a sidebar, but I have to know.

First step: My computer needs to be able to talk to the phone when I plug it in.  It needs to recognize my phone as a legitimate peripheral.

This should just take an addition to my udev rules.

I hunt for the right udev settings for the phone -- a two-and-a-half year old HTC magic.  This table reminds me that I can use per-vendor settings, so I add a line to /etc/udev/rules.d/51-android.rules:
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev" 
and run
sudo udevadm control --reload-rules
to get udev to re-read it.

Next, I look on my phone to see what version of Android it's running.  I remember that when setting up  the Eclipse project, I specified a minimum Android version the app would run on. I'd better check what version the phone has.

Menu->Settings->About Phone->Android version, tells me it's running 2.2.3 (Froyo).

Unfortunately, I don't remember what I said at setup (I bet I just took defaults), and it isn't obvious to me how to get back to that page. Googling tells me the information's in AndriodManifest.xml, so I look there and it says

android:minSdkVersion="8"
Great. I don't know which Android that is yet.


This page tells me that 2.2.3 is SDK API version 8.  Whew.

Plugging in the phone and permitting USB debugging (Applications->Development->USB debugging) makes /dev/sdc and /dev/sg2 appear, though nothing's mounted.

I bring up eclipse, pick MyAndroidProject, and press Run. The Choose a running Android device screen pops up and, sure enough, there's htc_t-mobile-mytouch-3g!

Crossing my fingers, I click on OK, and ... there it is.  MyFirstApp appears on the phone, and behaves just as it did on the Beagleboard.  There's even an icon for it in the list of apps.  How cool is that?

No comments:

Post a Comment