Skip to main content
October 4, 2011
Question

AIR for Android Captive Runtime

  • October 4, 2011
  • 8 replies
  • 19648 views

Is it possible to package android apps with AIR (or will it be) using Flash CS5.5? I don't see anything on the web about. Just how to do it with Flex and ADT etc...

This topic has been closed for replies.

8 replies

October 9, 2011

Hi,

I've made a complete working example for publishing an application with captive runtime, assets and native extensions starting from Flash CS5.5

I was able to make it thanks to hints and suggestions I found in this thread.

   

Note: english is not my native tongue so I hope you understand what I've written also if sometime it sounds "engrish".

Here it is the link to the zip file:

    http://www.genereavventura.com/hosted/Air3NativeExtensions/AirVibrate.zip

 

Requirements:

- You must have Flash cs5.5 pro (obviously)

- You must have installed the overlay for Air3.0 sdk on your Flash cs5.5 pro

Here it is a link that explain how to accomplish it: http://forums.adobe.com/message/3939712

Here the steps I made.

1) Open Flash CS5.5 and create a new AIR for Android application

2) Add the swc to the libraries used by your FLA (open Actionscript 3.0 settings and add "VibrationActionScriptLibrary.swc")

   Btw, you can find this "ready to use" native extension inside the zipfile that you can download from here: http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/vibration.html

   However in my example you will find also a directory named "extension" that contains it.

3) Open and then close the "air for android settings": by doing this Flash will create yourapp-app.xml file in the directory where your FLA resides.

   For example my fla is named "vibrate.fla" so Flash created for me a "vibrate-app.xml" file.

4) Make a copy of this "vibrate-app.xml" file by naming it "real-vibrate-app.xml" (or choose whatever name you want)

   I've done this because after modyfing the original one by adding the <extension> tag (see below) I wasn't able to test my app from within Flash IDE (when I compile it it simply doesn't start)

   Instead by doing this all worked fine.

5) Edit the "real-vibrate-app.xml" file by adding somewhere these lines (I added it just before the <initialWindow> tag)

    <extensions>

      <extensionID>com.adobe.Vibration</extensionID>

    </extensions>

6) Add <uses-permission android:name="android.permission.VIBRATE"/> in the <android> <manifestAdditions> part in "real-vibrate-app.xml" file.

   You should do something like this:

   <android>

      <manifestAdditions>

        <![CDATA[<manifest>

          <uses-permission android:name="android.permission.VIBRATE"/>

        </manifest>]]>

      </manifestAdditions>

   </android>

7) Develop your application

   I made a simple one that loads an external jpg and shows it on the stage: then the user can tap on it to make the phone vibrate.

   The function "doVibration" is called only when the app is running on Android Device so I do not get any executions error when I run the app from within Flash Ide

8) Publish and test it to your USB connected device by launching the "publish.bat" file I have created

   Open a dos prompt and move to your project directory then type publish.bat and press enter.

   Note: it can be that you have to edit the bat file in order to change the path to the ADT tool that comes with Air3.0 sdk

   It should be in [your adobe flash cs5.5 directory]\AIR2.6\bin\adt (rememeber, you must have installed the Air3.0 sdk overlying the old Air2.6/2.7 in the AIR2.6 directory)

   Inside the bat file you can change easily the target type (captive or not) simply by commenting/decommenting the right line.

   Captive version is about 8Mb more than the normal one but the big deal is that the user that installs it do not need the air runtime installed on his phone!

   The "big line" that creates the package is the following one:

   call %ADT_LINK% -package -target %TARGET_TYPE% -storetype pkcs12 -keystore certificate/vibrate.p12 -storepass android AirVibrate.apk real-vibrate-app.xml -extdir extensions vibrate.swf icons assets

   where:

   call %ADT_LINK%          it's just the path to the ADT tool

   -package                 it's the command that we want ADT to execute

   -target %TARGET_TYPE%    captive/non captive version

   -storetype pkcs12        certificate related

   -keystore certificate/vibrate.p12  path to your self signed certificate

   -storepass android       certificate related, I created the example certificate with "android" password and this parameters tell ADT to always use it without prompting

   AirVibrate.apk           the name of the Apk

   real-vibrate-app.xml     the apk-xml to use that is the one we modified manually above

   -extdir extensions       it's the path to the directory that contains the native extension

   vibrate.swf              the main swf

   icons                    the icons directory

   assets                   the assets directory (where I put the external jpg)

That's all.

If everything is correct, the batch file creates the AirVibrate.apk then installs it on your attached usb device and run it.

When you tap over the Android image that will appear, your phone should vibrate.

Now.. does someone wants to develop a Native Extension to show Admob banners in our Android Air Applications?

If I missed something, please let me know.

Thanks

Colin Holgate
Inspiring
October 9, 2011

Thank you for that.

Here's another useful resource, Brent's iBrent YouTube channel:

http://www.youtube.com/user/iBrent

He has posted a few new ones today, that include things like how to overlay AIR3.0 onto CS5.5, and how to compile an app that has native extensions.

Inspiring
October 11, 2011

I have vibration and toasts working in my apps.  Agree that admob would be a great addition.  Another good one (if possible) would be a native listview control.  I cannot seem to find a good one made in flash that will allow me as good of a user experience as stock android.

October 9, 2011

Guys,

At last I found some time and managed to test both the captive package and the native extentensions.

All went well.

Now I have done "from scratch" an application that has the captive runtime and that vibrates the phone.

Thanks to everyone.

P.S. Obviosly now I'm wating for a native extension "officially" supported  for displaying Admob banners in my app and I'm done :-)

Known Participant
October 6, 2011

While I do not currently want to use CaptiveRuntime, I am wondering if it is easily added to an app that is being published with Eclipse?

I use Eclipse to easily test my apps with on my devices.

I publish my SWF in Flash Pro and move the swf to my Eclipse package and run it immediately on my device.

Participating Frequently
October 5, 2011

It can take the authoring tools (Flash Pro CS and Flash Builder) a cycle to catch up to new features in the runtime. I would expect full support for captive runtimes and native extensions in the next release of these products.

In the meantime, you can build your app in Flash Pro CS (for example), and do the final packaging step using the ADT utility from the AIR 3 SDK. Inconvientent, yes; but it can be done.

October 5, 2011

Yes this is exactly what I have in mind but I would be happy to see (for example) what is the complete adt command that Flash Pro calls in order to build the apk.

So I can copy/paste it and all I have to do is to add that parameter to activate the "captive mode".

Any hint?

Participating Frequently
October 5, 2011

So for a normal release-type apk you would use:

adt     -package

    -target apk

    -storetype pkcs12 -keystore ../myCert.p12

    myApp.apk

    myApp-app.xml

    myApp.swf icons

(All on one line, replacing the myXXX with the appropriate values for your app)

For a captive runtime apk, you would use (the target is the only difference):

adt     -package

    -target apk-captive-runtime

    -storetype pkcs12 -keystore ../myCert.p12

    myApp.apk

    myApp-app.xml

    myApp.swf icons

Inspiring
October 5, 2011

I have seen that but was hoping for something easier like adding an extension and then a simple AS3 call. 

Known Participant
October 5, 2011

I am using 3.0 and am experiencing only Good Things on Android Tablet.

I first used the Candidate Release and now the full version.

I am not using Captive Runtime as Android has AIR 3.0 public.

Inspiring
October 5, 2011

It would be nice to have the option for captive runtime since some people don't like the dependency and have no idea what Air is.  They may just uninstall your app thinking it is malicious because it will try to download something else when you launch your app (if they dont have it).  It would be sweeter if Google just bundled it in and updated it in the background like they do the market app.  The captive runtime is 1 aspect but really want to take advantage of native code like 'share' and 'toasts' for example.

Known Participant
October 5, 2011

You can use toasts, contacts, etc already using this technique:
http://www.jamesward.com/2011/05/11/extending-air-for-android/?replytocom=163323

October 5, 2011

So, anyone has any hint for building the captive version by starting from a FLA in Flash Cs5.5?

Inspiring
October 4, 2011

Agree, seems like there is support for Flex and Flash Builder but no love for the Flash CS5.5 I bought in May mainly for the "Mobile workflow".  I would also like to know how to use native extensions.

Known Participant
October 5, 2011

Are you saying you can't make Air apps for android through Flash 5.5 at all? Sorry, I don't know what captive runtime means..

Inspiring
October 5, 2011

@monkey500: iOS apps made with Air include the runtime as part of tha app.  Previous to Air 3.0, all android apps had a dependency in that all Android phones needed your app + the Adobe Air app to work.  With 3.0, it is now possible to bundle your app + the air runtime app in a single file or download so the user doesn't have to download the Air runtime to make it work.

I wish Adobe would be clear on the tools they make and when you should use one vs. the other.  I am starting to feel like the Flash Pro 5.5 I recently bought is not going to be updated to support these new capabilities (native code as another example).  If it is, they willlikely charge again.  If this is the case, I might as well just learn native development rather than trying to figure out all these other tools.