My first AIR for Android development experience

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!


35 Responses to “My first AIR for Android development experience”

  1. Great post. I too have recently started developing on Android using the AIR SDK, very exciting times ahead.

  2. very good thanks , I can’t even get the emulator to connect to the internet 🙂

  3. Great summary! I’ll certainly be trying this soon!

  4. […] Continue reading here: My first AIR for Android development experience […]

  5. HI, what build of AIR does your apk target?

  6. Very nice sample.
    I tried this and when activating the adt and after entering the password I got

    C:\Users\moshe\Downloads\Air-Flex\RunTracker\bin-debug\RunTracker-app.xml(28): e
    rror 103: application.version is an unexpected element/attribute
    error 104: application.versionNumber is required

    even though I put 1.1 in the RunTracker-app.xml

  7. Hi Devgirl
    the answer was in the question I had to change version to versionNumber in the app.xml

  8. I can’t even get the AIR runtime to install to the emulator on mac. I have no idea what I’m doing wrong

    can’t install ‘Runtime_Emulator_Froyo_20100705.apk’ because it’s not a file

    …is what terminal tells me. I’ve cd’d into my tools folder where I unzipped the apk from adobe. Yet, adb refuses to install it….anyone got an idea here?

    • devgirl Says:

      Hi Simon, unfortunately you have come across a bug that others of us have also seen. It appears to be related to the emulator only. I have heard there’s a bug tracking this, I will see if i can find more info about it and post it here. Thanks! Holly

      • well that’s a bummer. Guess I’ll have to get an actual device or see if the same problem exists w/ 2.1 . Thanks Holly

      • devgirl Says:

        It is a bummer, but I know that I used the 2.1 version ok with the emulator, so give that a try for now!

    • I had the same problem on a mac, here is how I solved it. When you download it, make sure you do save link as or whatever. When you see the icon of the file downloaded, it should be a file icon and not a folder. If the extension has a .apk.apk at the end, it should still install. Make sure you arent unarchiving anything on the apk.

  9. Very inspiring post! Thanks a lot. BTW, can you please shed some light on how AIR run-time fits into Android Software Stack? I doubt it uses Dalvik VM for accessing native capabilities of the device. Right? AIR (runtime) probably has some direct channels of communication with core (native) libraries. Maybe you have some links to materials where this architectural relationships between AIR and Android are discussed?

    • devgirl Says:

      Yes, AIR is actually running natively on Android. I can’t really give much detail on this other than point you to the documentation located on the prerelease site: , but they are continuously putting updates out so definitely check it out regularly. Thanks! Holly

  10. Hi Devgirl,

    Nice application. As far as I get I could never manage to build an air application that uses Application as it’s main class, either I can run yours.
    I wondered how do you get this running into Android 2.2 emulator since it always crashes on mine. Could you post some tip?
    I’m using the lastest air runtime and the android sdk 2.2 lastest revision.

    thanks in advance.

    • devgirl Says:

      Hi Rupert! Can you let me know what happens when you run it with Application as the main class? Did you set visible to true in the app-descriptor, and did you ensure you’re using the right AIR 2.5 build that supports Android?

      I actually built the posted apk version with Eclair, which is why it’s probably not working for you on the emulator, but I’m recompiling a new one for the Froyo build and will add it to the project and post it. Thanks! Holly

      • Hi! What happens is that the application seems to start whole screen turns white and then the emulator shuts down the application an returns to the apps main panel. It’s not just a problem with your application particulary but also happens if I build an air 2.5 application and use Application or WindowedApplication as main application file.

        kind regards,


      • devgirl Says:

        I just posted the 2.2/froyo version of the apk at the same location as the rest of the project (different name from the eclair one) I built this as a debug apk version so maybe you could run the adb logcat after installing it to your emulator and then run it on the emulator and let me know if you see some specific errors in the console? I added an update in my post about the whole debug option. Let me know what you find, thanks! Holly

      • devgirl Says:

        Rupert, I asked a few of my Adobe friends about this and heard that their is a bug with using the emulator with froyo where what you described will happen if you are using Spark components in your app. Apparently all MXML components should work. Let me know if you find this to be the case, thanks! Holly

      • Hi Holly,

        I have just installed the froyo version of your app on the android 2.2 emulator and it didn’t worked. Regarding trying to run the previous version of your app on eclair was not posible since I couldn’t find the appropiate air 2.5 runtime for eclair emulator on the pre-release site.

        I really appreciate your efford of clarifying this issue by asking your Adobe friends.
        It would be nice if they were made some reference to this issue on the prerelease site so we could have avoided all this fruitless bug hunting. A bit better documentation on prer-elease site won’t do harm.

        Thanks a lot again. I will keep an eye on your blog.
        best regards.

        Here is the log cat it’s even resumed is quite long so please remove it if you wish:
        I/ActivityManager( 63): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=app.RunTracker/.AppEntry }
        I/ActivityManager( 63): Start proc app.RunTracker for activity app.RunTracker/.AppEntry: pid=241 uid=10034 gids={}
        D/dalvikvm( 63): GREF has increased to 301
        I/ARMAssembler( 63): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x3486c8:0x3487d4] in 945931 ns
        D/dalvikvm( 241): Trying to load lib /data/data/com.adobe.air/lib/ 0x43e3d8f0
        D/dalvikvm( 241): Added shared lib /data/data/com.adobe.air/lib/ 0x43e3d8f0
        D/qemud ( 38): fdhandler_accept_event: accepting on fd 10
        D/qemud ( 38): created client 0x150b8 listening on fd 15
        D/qemud ( 38): client_fd_receive: attempting registration for service ‘sensors’
        D/qemud ( 38): client_fd_receive: -> received channel id 8
        D/qemud ( 38): client_registration: registration succeeded for client 8
        D/qemud ( 38): fdhandler_event: disconnect on fd 15
        D/ReleaseLogging: ( 241): 0
        D/dalvikvm( 241): GC_FOR_MALLOC freed 2531 objects / 201008 bytes in 122ms
        I/dalvikvm-heap( 241): Grow heap (frag case) to 4.233MB for 1680016-byte allocation
        D/dalvikvm( 241): GC_FOR_MALLOC freed 703 objects / 43984 bytes in 89ms
        D/dalvikvm( 241): GC_FOR_MALLOC freed 217 objects / 1693544 bytes in 141ms
        I/dalvikvm-heap( 241): Grow heap (frag case) to 3.146MB for 582416-byte allocation
        W/ActivityManager( 63): Launch timeout has expired, giving up wake lock!
        D/dalvikvm( 241): GC_FOR_MALLOC freed 8 objects / 480 bytes in 100ms
        I/ActivityManager( 63): Displayed activity app.RunTracker/.AppEntry: 10089 ms (total 10089 ms)
        W/ActivityManager( 63): Activity idle timeout for HistoryRecord{4400f358 app.RunTracker/.AppEntry}
        I/ActivityManager( 63): Process android.process.acore (pid 154) has died.
        I/DEBUG ( 31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        I/DEBUG ( 31): Build fingerprint: ‘generic/sdk/generic/:2.2/FRF91/43546:eng/test-keys’
        I/DEBUG ( 31): pid: 241, tid: 241 >>> app.RunTracker <<<
        I/DEBUG ( 31): signal 11 (SIGSEGV), fault addr 00000258
        I/DEBUG ( 31): r0 00000158 r1 00000001 r2 81a84b1c r3 00000f28
        I/DEBUG ( 31): r4 00000158 r5 00000100 r6 000000e9 r7 00000082
        I/DEBUG ( 31): r8 00000001 r9 814ed8bd 10 00000009 fp 45a22b68
        I/DEBUG ( 31): ip 81a84b1c sp be9c80b8 lr 8151784b pc 8153684a cpsr 00000030
        I/DEBUG ( 31): #01 lr 8151784b /data/data/com.adobe.air/lib/
        I/DEBUG ( 31):
        I/DEBUG ( 31): stack:
        I/DEBUG ( 31): be9c8078 8156dd75 /data/data/com.adobe.air/lib/
        I/DEBUG ( 31): be9c8088 be9c8114 [stack]
        D/Zygote ( 33): Process 241 terminated by signal (11)
        I/ActivityManager( 63): Process app.RunTracker (pid 241) has died.
        I/WindowManager( 63): WIN DEATH: Window{44018cc0 SurfaceView paused=false}
        I/WindowManager( 63): WIN DEATH: Window{44019570 SurfaceView paused=false}
        I/WindowManager( 63): WIN DEATH: Window{44017e30 app.RunTracker/app.RunTracker.AppEntry paused=false}
        I/UsageStats( 63): Unexpected resume of while already resumed in app.RunTracker
        I/BootReceiver( 63): Copying /data/tombstones/tombstone_06 to DropBox (SYSTEM_TOMBSTONE)
        D/dalvikvm( 63): GC_FOR_MALLOC freed 8208 objects / 420448 bytes in 333ms
        W/InputManagerService( 63): Got RemoteException sending setActive(false) notification to pid 241 uid 10034
        D/dalvikvm( 63): GC_FOR_MALLOC freed 584 objects / 211152 bytes in 222ms
        D/dalvikvm( 63): GC_FOR_MALLOC freed 349 objects / 15200 bytes in 322ms
        I/dalvikvm-heap( 63): Grow heap (frag case) to 4.943MB for 72720-byte allocation
        D/dalvikvm( 63): GC_FOR_MALLOC freed 280 objects / 14536 bytes in 155ms
        W/KeyCharacterMap( 118): No keyboard for id 0
        W/KeyCharacterMap( 118): Using default keymap: /system/usr/keychars/qwerty.kcm.bin

  11. I see in the bug fixes of the Air runtime release of 20100720 says
    “2635683 – Application using Spark components Crashes on Froyo Emulator”

    so I will give it a try a soon as I can.

    kind regards.

    • Yeap is running now. However when I click an input field the application seems to close/crash and ui elements seems very big and out of the visible are a of screen.
      I will do some tests later at home.

      thanks you.

  12. Hi Rupert

    I have the same problem and I saw what you found regarding
    “2635683 – Application using Spark components Crashes on Froyo Emulator”
    but the only findings in google were in french
    can you alaborate about what should be done


  13. Hi moshe,

    As far as I could try the crash problem does not happen anymore.
    To solve this issue you have to install the lastest Air Runtime For Android on the emulator and also update your Air sdk to the new released version.
    Then rebuild your project and reinstall the apk on the emulator.
    Take in mind that you must use Application and not WindowedApplication as the main project class.

    hope this helps,

  14. anangphatak Says:

    Thanks for the tute. However, I have this app in FlashBuilder 4. I am pretty sure I followed directions on prerelease and your blog.

    Till I did not add the argument “assets/images/*.png” to adt I did not even get the Adobe Agreement screen.

    However, I my app is getting stuck at the “progress bar” 1/3rd full.

    I am ok to share code as this is just a POC, but I would like to know what I am doing wrong.

  15. Hi devgirl,

    This url seems broken,
    Can you tell me how to get your RunTracker source code? or apk files, Thank you very much.

  16. Hi, I’m just getting started with AIR for Android and this is really interesting. I know I’m abit late but I’d be very interested to see your code and it’s coming up as not found in the link in your blog. Is it possible to repost it somewhere maybe please? Thanks. 🙂

  17. Hi im new and i’ve created 4 apps on the market and i am now selling one for £0.50.
    I just want to know can i create an app on eclair(2.1) and froyo(2.2).
    Is it possible and if please can you tell me how!!!

  18. i can’t install adobe air for my android emulator, teh web says invalid testig opportunities

    how should i test my app then?

  19. Great article, I had come across this a long time back and waited for something simpler. Life is much better for Flex developers like you and me now with Flash Builder Burrito:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: