Table of contents
27 June 2011
Familiarity with building RIAs using Flash Builder.
Flash Builder (Download trial)
Note: This is an updated and expanded version of an article originally written by Andrew Shorten.
Flash Builder 4.5 includes support for packaging Flex and ActionScript applications for Google Android, Apple iOS, and BlackBerry Tablet OS devices. The process for acquiring signing certificates and provisioning application packages for the various platforms differs significantly.
This article and video aim to help ActionScript and Flex developers complete the necessary steps so that applications built in Flash Builder can be deployed to Google Android devices during the development, testing, and deployment phases of the project.
For more information on packaging applications for other platforms please read the following articles:
Unlike developing for Apple iOS and BlackBerry Tablet OS, you can deploy applications to Google Android devices for testing and debugging purposes without signing the application package.
- Make sure the device is not connected to the computer and then go to Settings > Applications > Development and select USB debugging on the device (see Figure 1).
Figure 1. Enable USB debugging.
Connect the Google Android device to your computer's USB port.
On Windows you may also need to install a driver for the device; this may be supplied as part of the software package for your device or you can follow the steps outlined in the Flex documentation to install the Android USB device drivers.
To install and run the application on the device, you create a run configuration to run on a Google Android device.
- In Flash Builder, select Run Configurations from the Run menu or from the dropdown list for the Run button and click the new or duplicate button to create a new run configuration.
- Name the new configuration, set the target platform to Google Android, set the launch method to On device (see Figure 2).
Figure 2. Create a run configuration for running on a Google Android device.
- Click the Run button. Flash Builder packages the application as an APK file, transfers it to the device, installs the AIR runtime on the device (if not already installed), and launches the application (see Figure 3).
Figure 3. Install and run the application on the device.
- Look at the list of applications on the device. You will see your application listed using a default name and icon (see Figure 4). You will learn to customize the name and icon in a later section.
Figure 4. Locate the installed application on the device.
- Locate the Google Android package file, the APK file, in your project's bin-debug folder (see Figure 5). This is a debug version of the application for development. You learn to create a release version of the APK for distribution in the next section.
Figure 5. Locate the debug Google Android package created.
To debug an application on a device, you use Flash Builder to create and install a debug APK package just as you did for running the application on a device. For debugging, though, your computer and the device must be on the same Wi-Fi network. The USB cable is used to install the application on the device; the Wi-Fi network is used for all communication between the device and Flash Builder when the application is running and being debugged.
In Flash Builder, select your Google Android device configuration profile from the drop-down menu for the Debug button and click Debug.
If you get a dialog box asking for the IP address of the host computer, enter it.
Flash Builder installs and launches the application on the device as before, but now when a breakpoint in the code is reached, the application will freeze and you can use Flash Builder to step through code exactly as when using the device emulator
If you have trouble debugging on the device, check to see if you computer is on a VPN or using a firewall. If the computer is on a VPN and the device is not, you may need to take the computer off the VPN for debugging to work. If you have a firewall turned on, try disabling it. If you cannot or do not want to disable it, try opening port 7935, the port used by the Flash Builder debugger to communicate with the device.
To create a release build of the application for distribution, you need to sign the application package when it is created with Flash Builder. The digital signature has two main purposes: to provide significant assurance to your users that you are a trusted signer whose code will not do anything malicious to their computers and that the application they are installing has not been accidentally or maliciously altered since it was packaged.
You can generate a self-signed certificate using Flash Builder or you can get a certificate from a certificate authority. When using a self-signed certificate, the application pubilsher will show up as UNKNOWN. Google does not require certificates issued by a certificate authority.
For development, it is quick and easy to just use Flash Builder to create a self-signed certificate.
- Go to Project > Properties > Flex Build Packaging (or ActionScript Build Packaging for an ActionScript mobile project) > Google Android.
- Select the Digital Signature tab and then click Create (see Figure 6).
Figure 6. Navigate to the Google Android packaging settings.
- In the Create Self-Signed Digital Certificate dialog box, enter your name, country, and a password; select 2048-RSA as the type; and then save the P12 file to a location on your computer (see Figure 7).
You should sign all versions of the application (including updates) with the same certificate.
Figure 7. Create a self-signed certificate.
Before publishing your application, you will probably want to get a certificate from a certificate authority. You can get a security certificate from a trusted third-party vendor, a certificate authority, such as ChosenSecurity, GlobalSign, Thawte, or VeriSign.
For more detailed information on acquiring a trusted certificate, see the article Packaging Adobe AIR applications for the desktop.
When you have completed development and testing, you use the Export Release Build wizard in Flash Builder to create a release version of the application for publication on the Android Market.
Before using Flash Builder to create a release build of the application, set application properties and Google Android specific settings in the application descriptor file.
- Open the application descriptor file.
- Set the application's ID to a unique ID (reverse domain name notation is typically used), the name and filename to the value you want to appear on the device, set the versionNumber (you should update this for each release build posted to the Android Market), and any other info you want to specify (see Figure 8).
Figure 8. Set application info.
- Locate the icon tag and specify PNG files for the application icons (see Figure 9).
For Google Android applications, you should provide 36x36, 48x48, and 72x72-pixel PNG images, which are used for low-density, medium-density, and high-density screens, respectively.
Figure 9. Specify application icons.
- Locate the android tag and modify Android specific settings (see Figure 10). Usually, you just set the Android permissions needed by your application within this element.
- See Android settings in the AIR documentation for descriptions of these settings.
Figure 10. Set Android specific settings.
When exporting for the Google Android platform, you must sign the application with either a self-signed certificate or a trusted certificate from a certificate authority. Google does not require certificates issued by a certificate authority.
- Select Project > Export Release Build and make sure Google Android is selected as a target platform (see Figure 11) and click Next.
Figure 11. Export a release build.
- Browse to your P12 certificate, enter its password, and click (see Figure 12). The release version of the package file, the APK, is generated and the application is installed on any connected devices.
Figure 12. Specify Android packaging settings for a release build.
- Locate the application icon on the device (see Figure 13).
Figure 13. View the new application name and icon on the device.
- In Flash Builder, locate the release APK package (see Figure 14).
Figure 14. Locate the release APK package.
- You can now upload this APK to any application store like the Android Market. For info on uploading your application to the Android Market, see its developer documentation.
- An application created with the Flex 4.5 SDK requires Adobe AIR 2.6 or later to run. The required runtime version is specified in the application's application descriptor file (see Figure 8). If a device does not have the AIR runtime or the appropriate version of the runtime, the user will be prompted to download and install the AIR runtime the first time the application is launched on the device.
In this article, you learned to use Flash Builder to run and debug Flex and ActionScript applications on Google Android devices. You also learned how to create a release build of your application for distribution. For more information, see the following resources:
Documentation: Developing Mobile Applications with Flex and Flash Builder
- Run and debug mobile applications
- Package and export a mobile application
- Connect Google Android devices
Documentation: Building Adobe AIR Applications
Documentation: Developing AIR applications for mobile devices