Archive for June, 2010

My first AIR for Android development experience

Posted in Adobe AIR, Flex/AIR with tags , , , on June 28, 2010 by devgirl

I recently got a Nexus One phone and I’m very excited about the development potential with AIR, Flash Player and Android! Since this is a whole new world to me, I thought I would write up a post summarizing my first experience with Android mobile development. I had ventured down the iPhone/Objective-C path awhile back but the syntax was so different than my Java and other development experience and with my limited time for side projects it just wasn’t working for me. Being able to leverage my ActionScript/Flex skills for the mobile world is beyond cool! Before going into the details of my first little app however, I think it’s important to go over some terminology to clear things up for those who may not know all the mobile jargon.

iPhone: a type of phone designed by Apple (multiple manufacturers). Runs the iOS Operating System, same as the iTouch and iPad. Multiple models include iPhone 3G, 3GS and the recently announced iPhone 4, which will run the iOS version 4.
BlackBerry: one of the first smartphones to become popular among business users, and developed by Research In Motion (aka: RIM). Runs a proprietary BlackBerry OS.
Nexus One: a type of phone manufactured by HTC for Google, runs the Android OS
Droid: a type of phone made by Motorola, runs the Android OS
Android: Google’s mobile OS (Operating System) originally launched in September, 2008
Eclair : The codename for Android OS version 2.1
Froyo: The codename for Android OS version 2.2 – just recently announced
HTC : a cell phone manufacturer, like Motorola
apk : An android package file extension. This is the type of file needed to install to the Android OS.
Adobe AIR 2.5 – the version of AIR that has support for Android, with tools to package apk files from the command line. With this version you can turn an AIR app into an Android app. Adobe announced the AIR for Android Public Beta program in May, here are details of the announcement.

My first app…
Since I’m a big runner, I decided it could be useful to develop a run tracker application for my phone. Serious runners tend to keep track of their mileage, pace, etc. so they can track their progress for training purposes. So with this in mind I went into Flash Builder and created my ‘RunTracker’ project. It’s made up of some tabs that allow you to input your running data and calculate pace, as well as show your history and pace trend in a simple line graph. The app uses SQLite (local database built into AIR) to save the run data. Here are a few screen shots taken from the Android emulator. The code for the project and the 2.1 (Eclair) and 2.2 (Froyo) versions of the apk are located here for reference. The Froyo version was built as a debug version (see notes about debug below).

A quick summary of the steps is outlined below. More can be found in the developer documentation at the AIR for Android Public Beta site. The Developing_AIR_apps_for_Android.pdf is a must read document and outlines all of the steps in depth. There’s also a great article by Christian Cantrell on Adobe Devnet that goes into designing apps for multiple platforms and screen resolutions that is worth a read here too.

1) Download the AIR 2.5 SDK and Android tools. Everything you need can be found in the documentation once you sign up for the AIR for Android public beta.

2) Create your AIR app to be used for mobile. NOTE: You need to change the WindowedApplication to an Application tag and then be sure to set visible to true in your app-descriptor.xml file, for example:

                <!-- Whether the window is initially visible. Optional. Default false. -->

The following icon sizes should also be specified for low, medium, and high density screens respectively. This is the icon that will show on your phone menu.


3) Package your application using the adt command line tool and package an AIR application for Android. For example:
adt -package -target apk -storetype pkcs12 -keystore ../../myCert.p12 RunTracker.apk RunTracker-app.xml RunTracker.swf assets/runner72.png

UPDATE: If you want to create a debug version of your application so you can see errors and stack traces, you need to add -debug to the target such as:

adt -package -target apk-debug -storetype pkcs12 -keystore ../../myCert.p12 RunTracker.apk RunTracker-app.xml RunTracker.swf assets/runner72.png

Then install your apk to the device and while connected run the following command from the command line:
adb logcat

Then run the app in the device and you should see the trace of what’s happening in the console.

4) Install it to either the Android emulator or your smartphone device. NOTE: The emulator is VERY SLOW. I would HIGHLY recommend using a phone if you have one. I almost gave up on AIR for Android development when I had only tried the emulator because of the performance, but it’s a whole different experience when installing to your phone so don’t be dismayed! You can use the -r option to reinstall it after the first time. Make sure to exit out of the application before doing the re-install. You can specify a -d for the phone or -e for the emulator, but if you only have one of them connected or running it will use that one by default. For instance, since I have my phone connected and my emulator running, I would use this option to install to my phone only:

adb -d install -r RunTracker.apk

Also, as part of the development I noticed a few things to point out. Certain components don’t work so well out of the box without some tweaking. For instance on the Spark NumericStepper, the default arrow buttons were much too small to click on easily on the Nexus One. I decided to take advantage of the Flex 4 skinning features and create a custom skin for my NumericStepper with increment and decrement buttons that used icons and were bigger than the default ones. Since by default the keyboard would pop up on the Android device when the user clicked into the NumericStepper (so numbers can be entered versus using the arrow keys), I also added a restrict property to the TextInput part of my custom NumericStepper that would restrict the entered values to numeric only.

There are more features I plan to add to this little app, (geolocation APIs to actually track the run etc) and I’ll continue to play around with things as the AIR for Android features progress, but it was fun to get my feet wet and see what it was about. I encourage you to do the same. And if you’re a runner too, grab the apk and try it out!

Adobe AIR 2.0 Release Official!

Posted in Adobe AIR, Flex/AIR with tags , , , on June 10, 2010 by devgirl

Adobe AIR 2.0 was officially released today by Adobe. What does that mean to you as a developer? If you haven’t checked out the latest features in AIR 2.0 or Adobe AIR at all, now is the time! Adobe AIR allows you to build Rich Internet Applications (RIA’s) for the desktop. It offers all the benefits of an RIA outside the confines of a browser and provides access to the File System, local database (SQLite), online/offline capabilities and more. The version 2.0 released today adds native process support, multi-touch and gesture handling, microphone capabilities, socket communication and other important features worth checking out. I recently worked on a bunch of samples for Tour de Flex that show off many of the new features in Adobe AIR 2, they can be found here.

The Adobe AIR runtime and SDK are both downloadable for free. AND… one of the most exciting and compelling reasons you should make it a point to start building apps with AIR is that you will soon be able to go mobile! Check out the AIR for Android program to see how you can write AIR apps that run natively on your Android device! I’ve built a couple of apps myself for my Nexus One and I’m personally very excited about how easy it is. You can have the same application running from your desktop that could be communicating with a LiveCycle Data Services server or BlazeDS ported over to your mobile device in minutes. An example of one such application can be found here.

You can also check out the Adobe AIR Marketplace to find oodles of AIR apps for download.