Sunday, January 4, 2009

Installing Android Apps On A DEV-1 Phone

I may be really dumb, but it took me forever to figure out how to simply get an app installed on a physical phone. When I finally found out the tools to use, I was getting errors like the one below when I tried to actually copy the app over.

$ adb install ~/sandbox/HelloAndroid/bin/HelloAndroid-debug.apk
123 KB/s (6758 bytes in 0.053s)
pkg: /data/local/tmp/HelloAndroid-debug.apk

To do the install, you need to do two things. First, create a signed apk file, then copy it over. The signing process is straightforward once you have got your debug keyring set up correctly. For some reason my setup on ubuntu (32 bit) didn't work out right after installing the dev kit and trying to use the eclipse plugin. The debug keyring was unusable, so I deleted it and recreated it.

  1. rm ~/.android/debug.keystore

  2. /usr/lib/jvm/java-6-sun/bin/keytool -genkey -v -keystore ~/.android/debug.keystore -alias androiddebugkey -keyalg RSA -validity 100000 -storepass android -keypass android

Turns out the debug keystore is expected to have both a keystore and key password of android. Then the build scripts work. This command sets up the keystore so that the ant build script will create signed debug apps. However, as a separate problem, the Eclipse Android plugin doesn't generate the ant script.

Even though the plugin supposedly wraps the command below, I ran it again on my source directory and it created the ant files.

$ ${android-sdk}/tools/activitycreator --out HelloAndroid

I could then do an ant in the source dir and get bin/HelloAndroid-debug.apk. It was signed, as expected and that let me install it. After you've setup USB connectivity, and verified it with adb devices...

  1. Connect USB cable to phone

  2. Pull down notification window and let USB mount SD card

  3. Settings->Applications->Development->USB debugging (enable)

  4. $ ${android-sdk}/tools/adb install ~/HelloAndroid/bin/HelloAndroid-debug.apk

The output of the last command looks something like this:

137 KB/s (8323 bytes in 0.059s)
pkg: /data/local/tmp/HelloAndroid-debug.apk

No comments:

Post a Comment