Friday, 21 May 2010

Installing Adobe AIR runtime on Android 2.1 emulator

Here's a quick guide that I've put together on getting an Adobe AIR runtime installed in an Android emulator running 2.1 (Eclair). I haven't had any chance to do testing on this process, but the runtime seems to install OK. I'm off on holidays soon, so if I get chance I'll put up a quick post of how to create and install a Flash application, but I'm getting short of time, so here at least is a guide to installing the AIR runtime in an emulator running 2.1. Yes that's 2.1 not 2.2. 


First thing you'll need to do is to sign up for the adobe prerelease. Which you can do here:
http://labs.adobe.com/technologies/air2/android/

Once you've done that you'll get a login and will be able to download the software and documentation:

I'm not going to use the AIR for Android CS5 extension, so I've just down loaded the AIR for android builds and the related documentation. 

These are the options that you have to download the the AIR for Android builds. 



















As you can see there are runtimes for Eclair and Froyo, so even if you do not have a phone that is running Android 2.2 you can still have a runtime for Android 2.1. There is even a runtime emulator for Eclair so if you don't have an actual device with either 2.1 or 2.2, you can still try your AIR applications out in an emulator! Since I only have an emulator I'm going to use this runtime on my setup. So the runtime that we are interested in here is, Runtime_Emulator_Eclair_20100517.apk.

The fact that you can run applications on 2.1 is also born out in the FAQs:

To develop an AIR for Android application using the command-line tools, you will need a recent Flex SDK and the AIR 2.5 SDK available on the AIR for Android prerelease website. You'll use the Android SDK tools to install the application on a device or Android emulator.

I don't have a device that runs Android 2.1 or 2.2. So I'm going to install the AIR runtime in an emulator. First make sure that your Android SDK is updated so that it supports Android 2.1. Then go to the tools directory of you Android SDK installation and run:

android list targets

This will give you a list of target ids , at least one of which should correspond to Android 2.1. Once you have the correct target id for Android 2.1 you can then create the AVD with this command:

First we need to make sure the we have a AVD (Android virtual device) that  supports android 2.1.  using this command: 

android create avd -n avd2.1 -t 11

You should see something like: 

Created AVD 'avd2.1' based on Google APIs (Google Inc.), with the following hardware config:hw.lcd.density=160

To see the list of available avds use the command:

android list avds 

To start the emulator with our AVD we use the following command:

emulator -avd avd2.1

Once we have the emulator running with the correct AVD we can now try and install the AIR runtime!!

adb install \\Runtime_Emulator_Eclair_20100517.apk

From this you should see the following output:

950 KB/s (6784204 bytes in 6.968s) pkg: /data/local/tmp/Runtime_Emulator_Eclair_20100517.apk Success

You can also check on your emulator that the adobe AIR runtime is installed by going to Menu->Settings-Manage Applications and view the installed applications. You should see something like this:
















OK so that's the runtime installed now we just need to write a quick application and check that it runs. I'll try and do this soon, before I go on holidays this weekend hopefully. :)













11 comments:

  1. That was a nice help, thanks.
    Here is an article i wrote (in french) explaining how to build an Air for Android application and deploy it:
    http://www.flex-tutorial.fr/2010/07/11/air-android-autoriser-une-application-android-a-acceder-a-internet/

    Cheers,
    Fabien
    http://www.flex-tutorial.fr

    ReplyDelete
  2. I get this error from Terminal:
    can't install 'Runtime_Emulator_Froyo_20100705.apk' because it's not a file

    what does mean? I unzipped it to my tools directory straight from the download from adobe...

    ReplyDelete
  3. Not sure have you given the correct path to the file?

    ReplyDelete
  4. I'm pretty positive because if I change the path I get an error saying that it can't install because the file is not found. I've tried just about everything from ./adb install Runtime_Emulator_Froyo_20100705.apk to ./adb -e install -r Runtime_Emulator_Froyo_20100705.apk (like it says to do in the Developing_AIR_Apps_for_Android.pdf that comes with the SDK. I can't find this error anywhere online...I'm truly stumped. Here's a link to the post I made in the Adobe forums.... https://prerelease.adobe.com/project/forum/thread.html?cap=E30C51D41E3B4960BC4F1EBD76BEE24D&forid={DE38C2EF-3575-45B9-9320-F3D03884447D}&topid={0BC7627E-76D1-4EFF-B648-DA9D9965F74E}

    ReplyDelete
  5. This works fine for me. All i can think of is that you are trying to install a 2.2 runtime on a 2.1 avd.

    ReplyDelete
  6. unfortunately no. They are both 2.2 . I posted the same question on Devgirl's blog and she responded saying that it's a bug thats been reported w/ the emulator. :(

    ReplyDelete
  7. Ok well thanks for the update. I've not tried it with 2.2. All i can say is that it worked fine on 2.1.

    ReplyDelete
  8. Try without the 2 slashes

    adb install Runtime_Device_Froyo_20100802.apk

    ReplyDelete
  9. Simon I figured it out. I had the same problems as you. I'm on a mac too, coincidence? Here's the trick: download the file from Adobe and it comes as a zip. I bet you were extracting it like I was (it extracts into a folder, not a single file). Instead, just run adb on the zip file itself. Worked for me :)

    ReplyDelete
  10. Hi there, I'm trying to install the runtime for Eclair, but the prerelease site only have the runtime for Froyo. Is there a link where i can download the Eclair runtime?

    ReplyDelete