Monday, December 29, 2008

Android Pt. 2: Crisis averted

I made another attempt at deploying the test application, this time using the command line tool.


me@mrroboto:~/src/android-sdk-linux_x86-1.0_r2/tools$ ./adb -d install ~/picthere.apk
203 KB/s (12207 bytes in 0.058s)
pkg: /data/local/tmp/picthere.apk
Success


I'm not sure why I was getting the permissions problem when deploying from inside of Eclipse.

But in any case, the application has been deployed to my G1 and works as expected.

Android Pt. 1: Developing and deploying first steps

To get things rolling I took the Hello World app that I had initially created using the Eclipse plugin and modified it to show a couple of buttons that pop up dialogs. Most of the code was taken and adapted from the alert dialog example programs.

Everything worked out when running the program under the emulator. My next step was to see what it would take to deploy to the G1.

When I opened up the manifest.xml file in Eclipse I noticed a link that read, "Export the unsigned apk". I clicked the link but didn't see output in the Eclipse editor, nothing to suggest that anything had happened. But, when I checked my home directory, I did find a new .apk file.

Note: If you right-click your project in the Eclipse package view you will find a menu item under Android tools that performs the same export function.

According to Google's documentation, my next step was to sign the apk. Since I'm only testing a deployment to my personal phone, I was hoping that this would be fairly painless: I didn't want to mess around with the details of key generation right then.

I read that there is a debug.keystore that Eclipse uses when automatically signing debug builds for deployment to the emulator. I hoped I would be able to skip the keytool step because of this and use the same key generated by Eclipse. Skipping to the jar signing step, I ran the following.

jarsigner -verbose -keystore ~/.android/debug.keystore picthere.apk  PictHere

When prompted for a password, I used the android default which is "android" according to this page.


me@mrroboto:~$ jarsigner -verbose -keystore ~/.android/debug.keystore picthere.apk PictHere
Enter Passphrase for keystore: android
jarsigner: Certificate chain not found for: PictHere. PictHere must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.

Whoops. Wrong alias for the last argument. After correcting, all worked as expected.


me@mrroboto:~$ jarsigner -verbose -keystore ~/.android/debug.keystore picthere.apk androiddebugkey
Enter Passphrase for keystore: android
adding: META-INF/MANIFEST.MF
adding: META-INF/ANDROIDD.SF
adding: META-INF/ANDROIDD.RSA
signing: res/drawable/alert_dialog_icon.png
signing: res/drawable/icon.png
signing: res/layout/main.xml
signing: AndroidManifest.xml
signing: resources.arsc
signing: classes.dex


I verified that the apk (actually a jar file) had been signed as suggested by Google.

I had a bit of a hiccup during the next step: using DDMS to deploy the app to the actual device.

There is a DDMS perspective in Eclipse that is really very, very nice. Unfortunately, after plugging the G1 into my computer via USB, the emulator showed up and not my actual device. A number of posts suggested that the "Unknown Sources" checkbox must be enabled on the G1 (found under Settings/Applications). After checking the box, I plugged the G1 back in and restarted Eclipse, but no device listed---still just the emulator.

I decided to try it from the command line:


me@mrroboto:~/src/android-sdk-linux_x86-1.0_r2/tools$ ./adb devices
List of devices attached
emulator-5554 device


Nope...nothing there but the emulator.

This page suggested that I add udev rules. Made sense...need to give the USB device the right permissions. (I probably should have mentioned that I'm developing on an Ubuntu box.)


If you're developing on Ubuntu Linux, you need to add a rules file:
  1. Login as root and create this file: /etc/udev/rules.d/50-android.rules. For Gusty/Hardy, edit the file to read:
    SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
    For Dapper, edit the file to read:
    SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", MODE="0666"
  2. Now execute:
    chmod a+rx /etc/udev/rules.d/50-android.rules



After unplugging and re-plugging the G1, it showed up for the party...


me@mrroboto:~/src/android-sdk-linux_x86-1.0_r2/tools$ ./adb devices
List of devices attached
emulator-5554 device
HT849GZ16642 device



At this point I was confident that I would be able to see the device in the DDMS perspective in Eclipse. Sure enough, it was there.

But sadly, when I chose the "push file to device" and selected my apk, I got the following error:


[2008-12-29 21:35:22 - ddms]transfer error: Read-only file system


Could it be that I am not going to be able to copy my app directly to the phone? Apparently this is the reason I should have picked up the Android Dev Phone, at least according to this post, which states that the Dev Phone is the same as the G1 but "there are no software restrictions on the device, users can directly load their own applications and test code straight to the unit rather than just relying on emulators to test code."

We shall see...

Developing for the G1

I received a G1 for Christmas and can't resist the urge to write my first Android application. I'll share my experience here.

So far I've downloaded the SDK, installed the Eclipse plugin, wrote my first Hello World application, and examined many of the sample applications that come with the SDK. The framework is quite simple and elegant.

My next step: try out the deployment process. My simple program runs fine under the Emulator, but how difficult will it be to package and deploy it to my phone?

Sunday, November 09, 2008

Crap. Gmail IMAP doesn't support searching by header Message-ID

I just spent the last hour trying to figure out why my IMAP query is failing. I'm testing an IMAP integration with gmail. Here is my query:

>>> type, data = mail.search(None, '(HEADER Message-ID "<799d9ef60811090712j14c90d46hf9939af135dc5a19@mail.gmail.com>")')
>>> data
['']

I should have mentioned that I'm using python IMAPLIB.

Even though the message-id is valid (there is a message with this ID), nothing is returned. Why? It's just not supported. From google:

http://mail.google.com/support/bin/answer.py?answer=78761&topic=12762&disablechatbrowsercheck=1

Does Gmail support all IMAP features?

Gmail IMAP is a fairly complete implementation of IMAP, but the following features are currently unsupported:

  • \Answered and \Recent flags on messages.
  • Substring search. All searches are assumed to be words.
  • Searching arbitrary headers. Only some headers are available for searches: From/CC/BCC/To/Subject.
  • There is no SIEVE interface to Gmail filters.
  • Only plain-text LOGIN over SSL tunneled connections are supported.
Yep, that's pretty much the feature I needed. Poop!

Sunday, August 17, 2008

The other Devin Venable

The Internet is a lot like your brain in that it remembers a great deal of your past. That goofy question you asked another developer back in 1998 via a mailing list---a copy is still floating around on the net. Or what about that videographer friend who asks for your help on a project? Do you really want the world to see you through the prism of a music video on youtube? How about the online petition you signed when you were all worked up over a political issue?

Unlike your brain's recollection of that great moment twenty years ago, degraded and made fuzzy over time, the internet can quote your words verbatim. Like your brain, some memories will be lost---or buried so deep that they will never resurface.

The Internet is different in that it may have false memories about you. As a brain, it has more in common with the Star Trek Borg than one belonging to a human. This is the collective memory of millions. Fortunately, millions are not interested in you personally---unless you are Paris Hilton. But what about those who do write about you? And if something is attributed to you, is it the right you?

For the first several years on the Internet, I was the only Devin Venable around---as far as I could tell. Just as I had convinced myself that my name was one of a kind, a high school kid popped up, posting things that were sensible for a kid his age.

I'm sure as he posted that the last thing on his mind was keeping up my professional image on the net.

If your name is John Smith or David Lee, you don't have to worry about this. You are granted a certain anonymity because so many share your...John Doe.

So this other Devin is still around. He is in his twenties now. How do I know this? Because he talks about himself on sites like bebo and Facebook. I know a lot about him. I know that he likes to wear New Era baseball hats, listen to rap music, and---not that I wanted to know---that he wears boxers instead of briefs.

Then again, I really don't know him at all. I can't even be sure that he is one other person. I don't know anything other than the public details that he (or they or someone) is projecting on the net. Will he/she/it/they be pleased with the picture they have painted of Devin Venable in ten years?

This gets me to thinking about metadata. Devin Venable is a very distinctive attribute (or tag). But it's not a particularly useful attribute for grouping. Here are some seemingly common attributes of the members of this group (based upon what I know of the Devins on the Internet): [human, male, American, white]. This isn't very specific and, as the name Devin is sometimes given to females, non-whites, and non-Americans, the only truley unique attribute is that we're all human.

Name your cat Devin Venable and that goes out the window as well.

Wednesday, June 11, 2008

Jacob Kaplan-Moss In Tulsa

Last night Jacob Kaplan-Moss came to speak at the Tulsa Python User's Group meeting for June. He is one of Django's founders and one of the pair of Django's Benevolent Dictators for Life, the other being Adrian Holovaty.

Jacob gave a little background on the Django project and talked about the upcoming 1.0 release. He gave a date for the release, a news flash that he had yet to announced on the user group lists. I think he said September, but you probably ought to check the mailing lists to get the real dope.

Most interesting comments:

He called Kent Beck's unit test approach either "crap" or "bullshit"---I can't recall the exact term, saying that his problem with it was sitting down to design tests before writing functions, and testing for inputs that you will never realistically be pushing into the functions. (Hopefully I paraphrased him correctly here.) The gist of his point was the suggestion that the programmer should be trusted to do the right thing.

Jacob also told us that he was a surprised as anyone when Google announced that AppEngine was Django based (or inspired). Google had approached him several months before to discuss "something" but the conversation didn't happen because Jacob wouldn't sign an NDA.

Of course most of the conversation was about new features, but you can go out and find that information yourself.

After the meeting a few of us accompanied Jacob to McNellie's, a local pub, for a few beers.
My impression was that he is a reasonable, down-to-earth kind of guy.

Thursday, May 15, 2008

JAVA today

(I came up with this today while reviewing source.)

JAVA today: take a 40 line function, explode it into 80 objects, and call it an improvement.

__

JAVA is not a bad language. But the bloat and cruft is driving me crazy. If only I could do every project in Python.