In this chapter I will show step by step how to prepare an AIR for Android project in FlashBuilder, write a simple application and how to install it on the device.

1. Preparing Flex SDK Air eclaire for FlashBuilder:

  • Create a folder /flex_sdk_air_2.5_eclaire.
  • Copy a flex_sdk_4 into this folder.
  • Copy the Air 2.5 SDK (Download explanation in the previous blog post) into the same folder and overwrite the flex_sdk_4
  • Set a path variable to ADT:;C:\path\flex_sdk_air_2.5_eclaire
  • ADT is a powerful command line tool from Adobe for AIR and is included in the SDK.

    2. Create a new Flex Project –“HelloAndroid” – in FlashBuilder.

  • Select application type “Air Nature”.
  • Select Flex SDK Version AIR 2.5.
  • If the created SDK AIR 2.5 has not been added before to the FlashBuilder library path, it can be added with “Configure Flex SDK”, which will show the Library selection window.
    First time you need to “add” the path to the library.

  • Next confirm the output /bin-debug .
  • In the next window we need to do an important change to the "Main Applikation file". Change the default file extension for Flex nature .mxml: HelloAndoid.mxml to Actionscript nature .as, because AIR for Android still can’t handle Flex. It should look like this now: HelloAndroid.as
  • Finish.
  • 3. FlashBuilder has created 2 HelloAndroid-app.xml files in our project . One in /src and one in the /bin-debug folder. This configuration file for AIR applications must be customized in the /src folder.
    When build, HelloAndroid-app.xml in the /bin-debug folder will be overwritten automatically. The following 2 tags are important for an AIR on Android application:

  • < supportedProfiles>mobileDevice< /supportedProfiles>
  • < visible>true< /visible>
  • HelloAndroid-app.xml should look like this:

    < ?xml version="1.0" encoding="utf-8" standalone="no"?>
    < application xmlns="http://ns.adobe.com/air/application/2.5">
    	< id>HelloAndroid< /id>
    	< filename>HelloAndroid< /filename>
    	< name>HelloAndroid< /name>	
    	< versionNumber>1.2.3< /versionNumber>
    	< supportedProfiles>mobileDevice< /supportedProfiles>
    	< initialWindow>
    		< content>[This value will be overwritten by Flash Builder in the output app.xml]< /content>
    		< visible>true< /visible>
    	< /initialWindow>
    < /application>
    

    4. If notalready made, a certification needs to be created with the Command Line Tool ADT (in this case self-certified) :

  • In the main application path create a folder /cert for the certification. Dont copy it into /bin-debug for security reasons!
  • Open a Command Prompt in /cert, or cd to that folder from your /root directory. Type:
  • adt -certificate -cn SelfCerti 2048-RSA SelfCertiAndroid.p12 password

    Explanation:

    - -cn SelfCerti the abstract name (choose any name)
    - 2048-RSA or 1024-RSA as the Key Type
    - The filename SelfCertiAndroid.p12 (choose any name)
    - The required password!

    5. In main HelloAndoid.as class add a textfield with “Hello Android” and run the application once to build HelloAndoid.swf and overwrite HelloAndroid-app.xml in /bin-debug .

    6. With ADT Create a APK Version of HelloAndroid.swf for the installation on Android :

  • Move to the /bin-debug Folder and open a command prompt,or cd to that folder from your /root directory.
  • In my example the command looks like this:
  • adt -package -target apk -storetype pkcs12 -keystore ../cert/SelfCertiAndroid.p12 
     HelloAndroid.apk HelloAndroid-app.xml HelloAndroid.swf

    Explanation:
    - The certificate is one level above /bin-debug in the /cert folder, that’s why the path has to be ../cert/ SelfCertiAndroid.p12

  • After typing the required password, ADT builds the apk file in the /bin-debug folder.
  • The complete projects file system should look exactly like this now::

    Now lets move the application to the connected device:

    adb -install HelloAndroid.apk

    READY!


    2 Responses to ““Hello Andoid” with AIR and FlashBuilder with Windows on my Motorola Milestone – Part 3 – Preparation FlashBuilder”

    1. That you only need guidance, is astounding. Before you post the definition is basically a spectacular, I can assume you may be a professional in this field. Very good, with your permission let me grab your RSS feed to keep up with the incoming release date.Thanks a million and asked to maintain the operation of fabulous.

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

     
    Get Adobe Flash player