Creating a Flash Builder Android Project
This post and it’s brother Creating a Flash Professional Android Project are going to be really short and sweet. I just want to make sure that there are no places for questions.
If you are starting with this post I recommend actually starting with a previous post introducing AIR for Android Development. There is a ANT file there that you will want to have.
FYI: All these steps are also available in Developing AIR Apps for Android PDF provided by Adobe.
Unlike Flash Professional we won’t be able to create an .apk file from our IDE. We can debug from the Flash Builder IDE, as shown by Renaun. That being said, that is where my ANT build file is even more helpful as it can package your application into a .apk file quickly for you.
Let’s set up this project.
Step 1: Startup
Create a new Flash Builder Project. File > New > Flex Project.
Make sure the application type is Adobe AIR and that you are using the SDK that you created with the AIR 2.5 SDK.
Then click next twice or until you get to this screen.
Change your main application file to “[Your Application Name].as”. By default it will try to create an MXML file, but as we are trying to make an AS3 project we need to change the file extension to being “.as”.
It’s also good practice to change your application ID to be something a bit more unique – I always just add in reverse domain extension to it.
Click Finish
Step 3: Program
You should now have an application that looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 | package { import flash.display.Sprite; public class HelloWorld extends Sprite { public function HelloWorld() { } } } |
You can keep programming your application to whatever you want. As I just want a quick application that shows Hello World so that we can continue, my application is going to be very simple.
My Application:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | package { import flash.display.Sprite; import flash.text.TextField; public class HelloWorld extends Sprite { public function HelloWorld() { var textField:TextField = new TextField(); textField.text = "Hello World"; stage.addChild(textField); } } } |
Step 4: Setup your descriptor file
First thing you should do is make sure that your application descriptor namespace includes “2.5″:
1 | <application xmlns="http://ns.adobe.com/air/application/2.5"> |
If you are using the right SDK, this shouldn’t be an issue.
We only need to change a few attributes in the application descriptor file to get things going. Any other changes that we need to make will be more specific for your application.
In the “initialWindow” tag find “visible”. Make sure it is set to true.
Now find “supportedProfiles”, set this to mobileDevice.
Now go to the “content” tag and change it to “[Your Application Name].swf”. Flash Builder typically switches this name out for us, and I could do it in my ANT file. But I can be lazy at times and would prefer just to set this value. Especially since this application descriptor belongs to the one specific application.
Step 5: Package your application
Your application is now ready to be changed to a .apk file for release. This is also when I will diverge from the Adobe PDF. See, I don’t like command line. So I created that nifty little ANT file to do everything I need. Now go get that ANT file and add it into your project and make any changes necessary to the build.properties as described previously in the last post.
With the settings changed to your specific computer we are good to go. You can either run an ANT file from command line or from your IDE.
From the IDE:

Here I right-clicked on the build folder and went to Run As.
Or from your command line you can run the ant file. Just “change directory” to your project holding the build.xml. Here you can type in one of two commands.
1 | [Hello World Directory] $ ant |
1 | [Hello World Directory] $ ant -buildfile build.xml build |
Both mean the same thing as the build target is the default target in ANT and the build.xml is the default file. If you wanted to run a different target you could.
To run get_devices
1 [Hello World Directory] $ ant -buildfile build.xml get_devicesTo run start_up_manager
1 [Hello World Directory] $ ant -buildfile build.xml start_up_manager
After you run the build target you are good to go. The ANT file will spit out your .apk file in a release folder. That’s it, you are ready to get away from the Actionscript and into the Android release process.







[...] This post was mentioned on Twitter by tony murphy and Ultra Red, karannnnnnnnnnn3. karannnnnnnnnnn3 said: Creating a Flash Builder Android Project: This post and it’s brother Creating a Flash Professional Android Project… http://bit.ly/cocMCo [...]
[...] – Building the Hello World Application in Flash Builder [...]
First off a huge thanks Jon! I’ve come very far with your tutorials but running into a few problems. I have everything installed and the project setup. My issue is a build failure with ANT. I’m getting the following error:
Buildfile: /Users/JavierJulio/Projects/MobileTest/build.xml
BUILD FAILED
/Users/JavierJulio/Projects/MobileTest/build.xml:13: taskdef class flex.ant.MxmlcTask cannot be found
Total time: 124 milliseconds
I’ve installed JDT for my Eclipse install so I’m running the ANT build from Eclipse. I don’t understand though why it can’t find the MXMLC task. I have everything pointed to the right folder. Any ideas what could be wrong? I’ve double checked and my FLEX_HOME and FLEX_TASKS variables are correct.
FLEX_HOME=/Applications/Adobe\ Flash\ Builder\ 4/sdks/4.1.0_AIR_2.5
FLEX_TASKS=${FLEX_HOME}/ant/lib/flexTasks.jar
Verified that these file paths auto completed in Terminal. I was reading the README file in the sdk’s ant folder and it mentioned including “flexTasks.tasks” as one of the taskdefs. Also that ant folder contains a build.xml file that I can see is defining the flexTasks. Shouldn’t I be referencing that somewhere to make sure its getting built? I know I’m just missing the last piece to run this. Hope you can help. Thanks!
@Javier hmmm, that is odd. Have to ask, have you made any other changes that I should know about?
No I just downloaded your build.zip and change the file paths to match mine in the properties files and then changed the app name to match what I have which is MobileTest. I noticed the build.xml file you have just has:
But when going to the /{fbinstall}/sdks/{41wAIR2.5}/ant/ folder I opened the README file and read that apparently I need to do the following:
Place flexTasks.jar into the lib directory of your Ant installation.
Alternatively, you can specify the location of the JAR file as an
argument to Ant, as the follow example shows:
ant -lib /flexTasks.jar .
In addition to this, you must include the following line in any build
file that uses the mxmlc or asc tasks:
.
Have you done this before? I tried running the ant lib command above but getting errors on finding flexTasks and if I just include the taskdef doesn’t seem to do anything. Do you remember doing anything that was mentioned above?
@Javiar Do you know what version of ANT you are using?
We figured out @Javier’s issue offline. Make sure to set your FLEX_HOME path correctly
[...] post and it’s brother Creating a Flash Builder Android Project are going to be really short and sweet. I just want to make sure that there are no places for [...]
Hi,
I’m having a problem when trying to debug on the device. When just building everything seems to go fine. These lines show up while building:
Buildfile: /Users/jgondek/Adobe Flash Platform/Experiments/TEST_AIR/build.xml
debug_on_device:
-preclean:
[delete] Deleting directory /Users/jgondek/Adobe Flash Platform/Experiments/TEST_AIR/release
-init:
[mkdir] Created dir: /Users/jgondek/Adobe Flash Platform/Experiments/TEST_AIR/build
[mkdir] Created dir: /Users/jgondek/Adobe Flash Platform/Experiments/TEST_AIR/release
-compile:
[mxmlc] Loading configuration file /Applications/Adobe Flash Builder 4/sdks/AIR 2.5 for Android/frameworks/air-config.xml
[mxmlc] Adobe Flex Compiler (mxmlc)
[mxmlc] Version 4.1.0 build 16076
[mxmlc] Copyright (c) 2004-2009 Adobe Systems, Inc. All rights reserved.
[mxmlc] command line: Error: configuration variable ‘file-specs’ value contains unknown token ‘app.file’
Any ideas of what is wrong?
[mxmlc] Use ‘mxmlc -help’ for information about using the command line.
BUILD FAILED
/Users/jgondek/Adobe Flash Platform/Experiments/TEST_AIR/build.xml:277: The following error occurred while executing this line:
/Users/jgondek/Adobe Flash Platform/Experiments/TEST_AIR/build.xml:50: mxmlc task failed.
Total time: 2 seconds
Interesting. What is the name of your application and what is the name of your application descriptor file?
Sound be something like: Main.as and Main-app.xml
Well,
none of those… Its TEST_AIR.as
Dang, I see what happened. I accidentally uploaded a build file before I added in the prompts to the targets. When I get to a computer later I’ll upload the correct version. If you are comfortable with ANT you can add in the code by adding prompting to build or set the value in build.properties. Sorry for that.
That is okay for it to be TEST_AIR.as as long as you have the application descriptor file set to TEST_AIR-app.xml. But there is still an issue that I need to update
Well,
I’ve worked with AIR before and work in AS3 all the time but never used Ant. In my country it’s 11:33 pm and I should be sleeping now, but I just bought some little device that doesn’t let me go to sleep
Thank you for a fast response, I’ll check if it helped after work (in next 14 hours I think).
The quick fix is to change
name=”debug_on_device”
To
name=”debug_on_device” depends=”-prompt_for_app”
I will post the fix in a few hours
@jgondek updated the files so they all work properly. however there is no easy plugin to the flash builder debug. All you debugging would need to be done via command line. not fun