How to create updater for AIR application bundled with captive runtime? - actionscript-3

What would be the logic of updating mechanism for AIR application with captive runtime?
Application should be distributed for Windows and Mac.
I got stuck here:
Note that this does not necessarily mean that you need to implement your own auto-update mechanism. If you use a commercial tool to create your installer, it may include auto-update mechanisms that you can leverage. On the other hand, if you do need to write your own update mechanism, you should find the URLStream, File, and NativeProcess APIs handy in implementation.
after reading it at: http://www.adobe.com/devnet/air/articles/air3-install-and-deployment-options.html
Is it something like (for Windows, after app is installed with some .exe or .msi installer):
upon starting app, check for new version
if there is new version, download it
overwrite existing app files and AIR runtime files
It should be forced update, before starting app.
How to overwrite running app? Or to make another app (updater) for replacing files, and after that start main app with NativeProcess?

For Windows I use the Native Application Updater
http://code.google.com/p/nativeapplicationupdater/
and WinRAR SFX archive (.exe) to auto update my captive runtime apps.
Native Application Updater will check the version, download your new exe, close your app and run that new exe.
In the SFX options:
I use absolute path, something like: %USERPROFILE%\AppData\Local\com\thenewkid\appname\
Under "Modes" you can select "Hide All" in Silent Mode. Under "Setup" you get it to run your application.exe after extraction.
You can keep the update size low by removing the Adobe AIR folder until a new version of the SDK becomes available (i.e. just had to push a larger update out recently for 3.3)
For MAC I use Installer. It isn't as silent as the Windows Updater as the user will have to click through a couple installer prompts but it allows you to put it in their home directory so administrative privileged aren't required which is what I find the most useful aspect of captive runtime.

Basically, you should have your app point to some XML file on your server which will contain things like newest version number, path to new files on server etc.
You can use a separate app to do the restart but keep in mind that since you are using Captive Runtime this will mean another 40-60MB just for the updater (unless you use some non-recommended hacks).
It would probably be better to just prompt the user to restart after you download the update.
The trick is not to overwrite the EXE but instead to overwrite the SWF (and any other files that need updating). From what I can tell, the EXE is simply a pointer to the XML manifest and the SWF.
You should not be updating AIR runtimes file every time - only for critical updates (since they are large files).

For the restarting of AIR in captive runtime this works for me on Mac (have not checked for Windows yet) (Note: UpdateAutoTest was the name of my app):
var appLauncher:File;
appLauncher = new File(File.applicationDirectory.nativePath).parent.parent.resolvePath("Contents").resolvePath("MacOS").resolvePath("AutoUpdateTest");
var npInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo;
npInfo.executable = appLauncher;
var _args:Vector.<String> = new Vector.<String>;
//_args.push("-a");
//_args.push();
npInfo.arguments = _args;
var np:NativeProcess = new NativeProcess;
np.addEventListener(NativeProcessExitEvent.EXIT, npExitHandler);
np.start(npInfo);
exit();

There is no need to overwrite. Have the user download your new package and launch it. AIR will know that package is already installed as a previous version and will prompt the user if he wants to update.
So the workflow is : check if there is a newer package, alert the user there is one, have him download and launch it. Air will manage the updating.

Related

WP8 - Re-using a native DLL through Windows Runtime Component

I have a native dll that I'd like to use in a WP8 project that I'm working on. I've done some research and have created a C++ Windows Runtime Component (WRC) to wrap the native DLL. The WRC project uses a .lib file, and my WP8 application calls the WRC project.
My solution compiles all fine, but when my application makes a call to a method in the native DLL, I get a The specified module could not be found. (Exception from HRESULT: 0x8007007E) exception.
From reading around it seems like the dll is not being loaded. I've copied all relevant dlls to the output dir of where the .exe file is and also in various places but the error keeps showing up.
If anyone could point me in the right direction I'd be very grateful. Also if more info is required I'll post that up also.
The DLL must be included in your XAP package. Something you can see being taken care of in the Output window when you build your app, it starts with the "Begin Xap packaging" messages and then lists all the files that get added. The runtime error says it is not being included.
There is remarkably little guidance on how to ensure that a file gets included in a phone package when MSBuild cannot figure out the dependencies by itself. It certainly won't for your DLL, no way the build system can tell if it isn't a project in your solution. Seems you're operating a bit on the bleeding edge in this case :)
But this works well when I try it, going by the MSBuild output and not by actually testing it: Project + Add Existing Item. Navigate to your DLL and select it. Select it in the Solution Explorer window and look in the Properties window. Ensure that "Build Action" = Content, Copy to Output Directory = "Copy if newer". Rebuild, you'll now see the file getting added to the XAP. Which should solve this particular error. There might be others :)
Windows Desktop or Windows Store native DLLs are not binary compatible with Windows Phone, even if they are built for the same CPU architecture.
Therefore you will need to recompile your native DLL for the Windows Phone toolset.
About Windows Runtime Components:
On Windows Phone a Windows Runtime Component is itself a native DLL (.NET is not supported on the phone). The binaries of Windows Runtime Components cannot be shared between Windows Store apps and Windows Phone apps.

IBM Worklight - How to silently update the application's web resources?

I want to silently update the web resources of my application using the Direct Update feature.
I did not manage to find any related documentation to do that.Can anyone give me an idea on how to proceed?
I generated an apk for my application say app version 1.0.
With some modifications in UI I generated one more apk say version 1.1.
Now again with some change i generated apk for third version say v 1.2.(latest)
Now My intention is if a user has apk 1.0 then it should update the user that this version is deprecated and i will provide a link to get the latest version.
If the user has apk version 1.1 then it has to alert the user that an update is available.
All these things I am able to achieve using direct update. But when I am trying the same for silent update it is not working.
The property you're looking for is updateSliently set to true in initOptions.js.
For this to work, it is required that connectOnStartup will be set to true as well.
It seems to be working in Worklight 6.0, but fail in Worklight 5.0.6; I have opened a defect for this.
In any case,
The steps you have described are INCORRECT. These are the steps for Direct Update, silent or not:
Create an app, add environment
Build all and deploy
Launch app on device
Change WEB RESOURCES in the app (images, HTML, JavaScript)
Re-build and deploy the app
Re-open the app / bring it back to the foreground
If you are changing the version id, the changes you will make to the web resources will not reach their destination.
Changes done to version="1.0", will reach only apps running version "1.0"; if you up the value then changes will only reach apps of that new value.

AIR file too big, breaks during installation

A client is having me convert an HTML5 video web application that I've already built into an AIR app.
The end users are going to need this to work with no internet access, so I MUST include a LOT of video files with the installer. This works fine on my machine, but my client can't install it because the .air file is too large and they don't have enough RAM. We'll need this installed on a number of laptops that aren't super powerful.
My SDK is up to date and we're using AIR 3.1.
Has anyone else run into a similar situation? Is there any workaround? For instance could I either include both the installer and the .air in a zipped folder, then have the installer move the video files to the appropriate location, or use AS to have the installer download the files (they will have internet access when installing).
I'd recommend you not to include heavy video files into your application. Downloading assets from web is a descent idea, I use same technique for several museum touchscreen apps.
So here's workflow: on startup app tries to connect to "assets server" and request list of files to download. It can be list of all the files, or list of files that have been updated/added since timestamp that you pass with your request. Then you download them to File.applicationStorageDirectory. Not to have mess in that directory I put all of them to "cache" subdirectory.
In case there's no internet connection for some reason when you install that app, you can have all that "cache" folder on your memory-stick/externalHD so you can manually perform that downloading process.
If you use Greensock's LoaderMax: I've written a simple URLStreamLoader that extends LoaderItem, handy for downloading files. Can share that.
The problem is quite obvious: the Adobe AIR provided installer for deploying your application is lacking.
However, Adobe recently released a new feature for deploying Adobe AIR apps: "runtime captive bundle" (Windows or OSX).
Which means 2 important things:
You receive an .exe which no longer requires an user to have Adobe AIR runtime installed (and no more incompatibilities when targeting multiple Adobe AIR runtimes).
You are no longer provided with an installer, and you have to find your own (which solves your problem halfway).
Target bundle when "compiling", and then just use a better installer (Windows or OSX) - think you are just deploying a normal application (worked for me:) ). There are too many installers arround to mention.
Your installer of choice + bundle compiling, together solve your offline installation requirement and the memory exhausting issue.
Packaging a captive runtime bundle for desktop computers

Android -- Auto Install third party apk file from a web server

How to install the new version of apk file from a web server automatically instead of manual install(Downloading the apk and clicking the same).Upon starting the application , it should query for the higher versions available in web server and based on that the new version should be installed in the device.The updation may be either with user confirmation or background process.
You cannot auto-install any apk without the user's permission. You can at best, download the apk file, and then prompt the user to let him know that you want this application to be installed.
So, if the web app has the necessary APIs, you could write some code to query and get the latest versions available, and then finally download and prompt the user.
There is an intent to launch this confirmation activity.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.fromFile(new File("link to downloaded file")),"application/vnd.android.package-archive");
startActivity(intent);

JavaFx 2 applicaton does not run when i run it through HTML page

I have downloaded the javafx 2 samples and want to run in from its HMTL. For example there is one javafx application called BrickBreaker. For the specific sample the following files exist : BrickBreaker.jar, BrickBreaker.jnlp and BrickBreaker.html
When double clicking on jar or jnlp the application runs as expected but when i click on the html the application does not run. Instead i get the message "View the conectes of the page. Please install javaFX"
Why is that happening ? ( i have the javafx installed as the application runs when choosing the jar and jnlp files). My guess is that the html should be called from within the context of a webserver meaning that i should deploy my application first to a server and call the url from my explorer. For example if using glassfish i should call the url http://localhost:8080/Brickbraker
The problem is that i don't know how to deploy the javafx application in the server.
i tried to copy paste all the above three files in the autodeploy folder but it didnt worked...
Could you please help me?
Thanks in advance
EDIT: some more info - I have installed JDK 7 and JavaFX SDK 2.0.2
No, JavaFX is client technology, you don't need Glassfish to run it. JavaFX should run in browser the same way as Java plugins do.
If you can't run an application directly from html file it means your browser doesn't recognize you have runtime installed.
There can be next reasons for that:
JavaFX runtime is actually not installed (check in Windows Control Panel)
pure java plugin is not installed (you can check on java.com)
javafx runtime is 32bit and you are using 64bit browser (or vice versa)
you are using not supported browser (e.g. Safari)
you are using not supported system (at this moment, January 2012, only Windows supports runtime)