Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Mobile / Android

Flex 4.5 for Android: Getting Started with Flash Develop

5.00/5 (3 votes)
20 Jul 2011GPL33 min read 25K  
Flex 4.5 for Android : Getting started with Flash Develop

Following on from my last post about getting up and running with Flex, here is how to quickly get an end to end Android dev environment up and running with Flash Develop.

You can download the complete Flash Develop project from here. But you will need to update the SDK paths.

Step 1: Install Flash Develop and the Latest Android and Flex 4.5 SDKs

Step 2: Create a New Flash Develop Project

Create a new Air Flex 4 Projector project and give it a name e.g. “MyFlexProject”.

Create a new flash develop project

Step 3: Enable the Project for Flex 4.5 Compilation

In FlashDevelop, go to Project -> Properties and under the “Output” tab, you will need to create a custom command to test your movie as follows: $(FlexSDK)\bin\adl.exe;application.xml bin. Replace $(FlexSDK) with the path to the flex 4.5 SDK that you downloaded.

Set the platform target

Under the “Compiler options” tab, set the “Custom path to flex sdk” property to your flex SDK bin directory that you downloaded earlier.

Add the following additional command line arguments:

-swf-version=11
-target-player=10.2

Set the compiler options

Step 4: Create the application.xml File

Now we need to replace the application.xml with the latest supported version from the SDK. I always start with the Application.xml content that comes with the SDK to pick up any changes. In your flex 4.5 SDK directory under “Templates\Air”, copy the contents of the descriptor-template.xml and paste into your application.xml file.

Step 5: Setup the Package and Deployment .xml Files

Open the PackageApplication.xml and change the adt call to:

call adt -package -target apk-emulator %SIGNING_OPTIONS% %AIR_FILE% %APP_XML% %FILE_OR_DIR%

Change the signing options by removing the TSA option:

set SIGNING_OPTIONS=-storetype pkcs12 -keystore %CERTIFICATE%

Change the AIR_FILE variable to point to an apk file instead of a .air file, e.g.

set AIR_FILE=air/YourProjectName.apk

You will also need to update all the references to “$(FlexSDK)” to the path of your flex SDK. The same will need to be done for the CreateCertificate.bat file.

Step 6: Create an Android Deployment bat File

Just to make things a little easier, create a deployment bat file with a call to…

call adb install -r air\MyFlexProject.apk

Create a deployment bat file

Step 7: Test Your Project

Build the project to test the new settings. If everything has been setup correctly, your project should build successfully.

Step 8: Package for Android

Now let’s package the application for installation on an Android device.

Run your CreateCertificate.bat file and then run the PackageApplication.bat file. For the package to work, you will need to ensure you have valid values set in the application.xml file. If all goes well, you should find a .apk file in the air sub directory of your project working folder.

Step 9: Deploy to the Android Emulator

Run the Android SDK and AVD Manager which you will find in your start menu once you have installed the Android SDK.

Android AVD manager

Create an Android Device which must be running Android 2.2 and above to be able to run the Flex 4.5 Air runtime. Start up the Device.

Android device

Step 10: Test Your Application on the Device

Just to make sure the environment is running smoothly; go back to Flash develop and open the main.mxml file and add a panel with a simple label control. You will need to change the Root “WindowedApplication” tag to a “Application” tag. WindowedApplication is not supported by Android.

Create a simple panel

Now Build the project and run it. You should see your Panel and Label in the Air debug launcher.

Debug your application

Now Install your application onto the device using the PackageApplciation.bat file and then run the DeployToAndroid.bat file that you created earlier.

Deploy your application

You should now see your application appear in the Apps on the emulator.

Your application should now be installed

After running the application, it should look as it did when you ran it in debug mode.

The running application

Enjoy!

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)