@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.
AIR 2.7 works well on Android. I haven't yet tried the release AIR 3.0 on Android (I can't find the SDK download page), so I'm not sure how it does. Aside from having to set the bitdepth to 16 bit to get the best performance, other people seem to have done ok with it. Some of the Android apps Adobe showed at the keynote speech were done with AIR 3.0.
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.
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.
So for a normal release-type apk you would use:
-storetype pkcs12 -keystore ../myCert.p12
(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):
-storetype pkcs12 -keystore ../myCert.p12
No, there's no command line interface within Flash Pro. Possibly you could script it with the Flash scripting interface, jsapi. (I've never done anything of the sort, so I'm not sure.)
The step-by-step is:
1. Get the AIR 3 SDK.
2. Create the app. At this point you should have a folder with the SWF, app descriptor, resources
3. Find your code signing cert.
4. Open a command/terminal window
5. change directories (cd) to the app folder
6. Run ADT (from the bin folder of your AIR SDK) with the options shown above
Thanks Joe Ward,
I appreciated very much your suggestions.
One more question: what if I have two subdirectories with assets, for example assets0 and assets1?
-storetype pkcs12 -keystore ../myCert.p12
Is this correct?
Thanks in advance
Yes. If you list a file it is included. If you list a directory, that directory and all its contents are included in the package. (For example, "icons" in the example is a folder containing icon files.)
For the gory details on the command line options, see http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac1e63e3d12994b39ff0-8000.html
(Except it seems, the -apk-captive-runtime option, which I'm working to get updated ASAP!)
This part "1. Get the AIR 3 SDK.", is proving to be a challenge. I have AIR 3.0 installed, and FP11, but I can't find a download link for the release SDK.The download button at the right of this page:
doesn't seem to do anything.
I sat down last night and took some time to try to figure this out. I was successful in taking my swf and getting a working captive android app. I was also able to get the native extensions working as well (vibrate on button press). It adds a lot of extra steps to the process but it is possible. One of the issues is testing, especially the native extensions. You have to create the swf and manually package it, then manually get it on your phone and install it (maybe there is an install feature in ADT but I haven't got that far, either way, still not as easy as clicking publish). It is ok if you want to build a captive app once you get your app finalized but without being able to quickly test the native extensions quickly from within Flash Pros publish, I will likely hold off on using native extensions until flash pro is updated or I really need it.
Now some results.
Captive app added about 8MB to my apk file size which is pretty consistent with what others have experienced on here as well. If you push a lot of updates, you may get a lot of angry users depending on data plan. Now, once you look at your app within Android file manager, it takes up over 25MB of space but approx 200k if you move it to SD (this is Gingerbread size, Froyo can differ in how much can be moved to SD). This is consistent with the new AIR in the market that is about 8MB file size but expands to 25MB once installed. This is about 9MB increase over AIR2.7 which weighed in around 16MB (expanded) I believe. Moving apps to SD will help some of the older phones with the file size but if they have 10 AIR apps, it could add up.
I am debating whether or not I should use the captive feature or not. Considering I can setup my android manifest to prefer SD card install, it might be worth it. I also did notice that some of my currently published apps had some strange behaviour with the new AIR3 runtime and I had to update them quickly, yet another reason you may want to use captive apps.
I'm still a bit confused.
I have to admit that I have still to try because lately I have not so much spare time.
I know now how to create captive apps.
What I do not know is how to use native extensions in Flash CS5.5
For example I downloaded the example "vibration.zip" from here
I got the swc and put it in flash library as I usually do when I use swc.
Then I add the code to my project in order to make my phone vibrate (and I added also the permission entry).
I compiled the whole thing and got no errors.
But when I try it in runtime I get a lot of errors coming from the swc
Obviously I think I will have to do it manually with ADT.
This means that I can test it only on my device and I have to put some sort of "if" in my code for excluding that code when I compile and launch it from Flash env.
Am I Right?
If yes, can someone drop some lines in order to add an extension when packaging with ADT?
Thanks in advance
You need to use command line ADT to compile. You also need to add -extdir "foldername"to the command line that has your android native code in it. In addition, you need to modify your XML file to include <extensions>. I just took the sample at the below link and looked at how they structered theri XMLs etc. I also got the toasts working.
One issue I ran into with AIR3 is that the soft menu key on Android tablets is missing. Apps I compiled in AIR2.6 SDK such as the sample "Options Menu" in the template show the menu key in Honeycomb. Same app compiled using AIR3 does not. Now I have users emailing me that are unable to get into the options of my apps and I have to ugly up the UI with a button. If you need this feature, please vote below:
To include a native extension in the package, add "-extdir dir-with-ane-files" to the command line after the application descriptor. E.g:
-storetype pkcs12 -keystore ../codesign.p12
Testing is a little more problematic until Flash CS supports native extensions. There are ways to do it on the desktop using the command-line ADL utility, but really, I think testing on the device is the easiest. (I do have to admit that I haven't used Flash CS to work with ANEs, only Flash Builder at this point.)
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 :-)
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:
- 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)
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:
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
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)
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.
Thank you for that.
Here's another useful resource, Brent's iBrent YouTube channel:
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.