Android Mobile Development
I am starting to write this post as I wait for a bunch of new packages to download and install from the Android SDK and AVD Manager. I’ll let you know now that so far I’ve really liked working on the Android Development Platform – especially with Air.
The tricky part isn’t writing the application. That part is easy and we know that part. The tricky part is building the .apk package and testing the application on an emulator or other valid device.
So that is what I am going to write about, the tricky parts.
- - Managing the Android Development Environment
- - Building the Hello World Application in Flash Professional
- - Building the Hello World Application in Flash Builder
Once you read through these posts you’ll have an up and going Air for Android development environment and an initial application to kick you off.
Starting these posts off I will add a few disclosers:
- 1. I am not a fan of command line.
- 2. I am not a fan of messing with the paths in my computer.
I am not a fan of command line
I just don’t like memorizing a ton of commands or having to go back and reference a ton of commands and paths. One small path issue and BAM nothing works and you have to read through a ton of mixed code to see where your problem is. Not fun.
I am not a fan of messing with the paths in my computer
Seems like every programming language I get into requires a bunch of path changes and if I move computers now nothing works till I set it up. Not fun. I also fear screwing up my computer.
In case you like setting up paths or want to know how there is a guide provided by Adobe called Developing AIR Apps for Android in the prerelease site. That PDF includes a section Setting the path environment variable. Follow that guide.
Solution
I like using ANT. I can set up all my paths in ANT and ANT works directly into your continuous integration environment. So if I move computers I can just set up my properties I’ll be good to go. Finally the amount of commands to memorize goes WAY down or you can just look into the ANT build file and see the available possible commands.
Expert tip!
You can always view the available targets in an ANT file in the command line by running the following command.ant -buildfile build.xml -projecthelp
Want to know what else is pretty slick? I’ve set up the ANT file for you. I’m thinking of making a nice GUI in AIR to help you out, but for now an ANT file will have to help.
Getting Started
The things you’ll need to get started with Air for Android.
- - Download the Android SDK
- - Sign up for the Air for Android Prerelease program
- - Download Air 2.5 from the prerelease site (if you don’t already have access to the prerelease site, you’ll have to wait for your email after you sign up for it)
- - Download the prerelease Runtimes (emulator and device)
- - Download the Flex 4 SDK
- - Combine the Flex 4 SDK with the Air 2.5 SDK
Creating a Project
AIR for Android currently works best with either a Pure AS3 project (no Flex) in either Flash Builder or Flash Professional. If you are building with Flash Professional, there is an extension that Adobe has provided for you to help speed up the .apk build process. If you go through Flash Builder you’ll have to make this file. Again, with the ANT file I am providing either is a very simple path, so choose the development environment that you prefer.
Setting Up Your ANT File
Once you have your projected set up you will be ready to add in the ANT build information. The ANT file that I will use for the rest of these posts is really easy to set up, just drop it (and base.properties) into your application in the root level.
This ANT file provides you the ability to install the device and emulator runtimes, install your application and test it on a device or runtime, set up a device, run the emulator and even run the Android Management device. Again, yes you can do all these things in the command line… but do you want to?
Then you need to create a build.properties text file. This is the file that you will put your own environment’s paths. So if you share this build file, everyone can have their own properties and the main build.xml is the same and unchanged.
build.properties
#FLEX_HOME=[path to your flex sdk]
#SDK_VERSION=[your flex sdk version]
#Android File Locations
#ANDROID_DIR=[path to the folder holding the android sdk (this is where I put the runtimes also)]
#ANDROID_SDK=${ANDROID_DIR}/android-sdk-mac_86
#EMULATOR_RUNTIME_ZIP=${ANDROID_DIR}/Runtime_Emulator_Froyo_20100909.apk.zip
#DEVICE_RUNTIME_ZIP=${ANDROID_DIR}/Runtime_Device_Froyo_20100909.apk.zip
#App Settings
#APP_NAME=[Your app name]
#APP_EXTENSION=[Your app extension (.as/.mxml)]
# Your IP Address
# this is for device debugging.
# you won't want to keep entering this in
# as you keep running debug apps.
# If you enter '...' for your IP Address,
# you'll be prompted to enter it each time.
# Which is ANNOYING!
IP_ADDRESS=192.168.0.10
## In case you don't know ANT
# <- the hash symbol is a "comment" (# = //)
#
#
# So you can 'uncomment' out the above lines to
# set your own variables and paths or you can
# change the paths to whatever you want in the
# base.properties. I just pulled out variables
# that I felt everyone would update to this file.
You’ll probably notice that I put my Android SDK in the same folder as my Flex SDK. This isn’t necessary, I just thought it’d be nice that all the information for my development environment would be in one location.
In upcoming posts we’ll go through how to use the ANT file and manage your development environment.
Good luck in your Adventures with Android.
Don’t miss this, this is the link for the ant files!
![]()
If you previously downloaded this ANT file please redownload it. I’ve added quite a few additions to it that should make your development much easier.
From here checkout how to manage your Android SDK environment, how to create a Flash Builder Android Project, or how to create a Flash Professional Android Project.






[...] This post was mentioned on Twitter by tony murphy and Ultra Red, karannnnnnnnnnn3. karannnnnnnnnnn3 said: Android Mobile Development: I am starting to write this post as I wait for a bunch of new packages to download and… http://bit.ly/aEDTCn [...]
Nice article,
if you ain’t a fan of the command line and would like a proper GUI, have a look at this one (still in beta phase):
http://www.webkitchen.be/package-assistant-pro/
Fabien
http://www.flex-tutorial.fr
@fabien I did see that and really liked it. But ultimately I also wanted to create something that would work in with a continuous integration system. But what Serge did was wonderful. My ANT file goes a bit further for my needs as it can also start up an emulator and install on a successful completion if I so choose.
[...] and packaged. This should be the most boring part but I was able to quickly adapt a great ANT file shared from Jonathan Campos in a recent [...]
[...] a multi-screen air application I stumbled on a couple articles by Jonathan Campos about Android Air Development. So I must admit that a lot of the ground work was allready done by both Jonathan and Marvin but [...]
[...] Le script fourni par Jonathan Campos ayant été développé pour Mac, j’ai rencontré quelques difficultés à le faire fonctionner sous windows. Aussi, je me suis permis de le modifier très légèrement mais vous pouvez le retrouver dans sa version originale sur ce post. [...]
Hi Jonathan,
one of my reader adapted your Ant scripts for Windows env. and rewrote it in french. There it is :
http://www.flex-tutorial.fr/2010/09/09/air-android-package-et-installation-d%E2%80%99une-application-en-un-double-clic-avec-ant/
Thanks for this tutorial,
Fabien & Mathurin
@fabien @mathurin great posts, glad it was helpful.
[...] This post was mentioned on Twitter by Jonathan Campos, Hannnnk. Hannnnk said: RT @jonbcampos: Thanks to everyone that came to my session. I am working on getting the slides up, but the info is here http://bit.ly/9zWars #airforandroid [...]
[...] Now that's the very basics of getting the project to compile right and get on to the Android device. Once you really want to put it on the device you'll want to build the application properly (non-debug) and a great short term way, until Burrito comes out, to do this is use John Campus's ANT scripts. [...]
I really have been enjoying your Air for Android posts. Question for you, utilizing AIR, can one make a widget for Android?
Steve
@steve Good to hear because there are more on the way. Currently Air for Android does not support widgets. There is an open jira bug but I couldn’t find it. You may want to start another one and let’s get the votes up for it!
Thanks Jonathan. Another question. New to Ant here, so bare with me. One road block I’ve hit is when I use more than one source folder in my project. I have a utility AS3 library that I use for all of my projects. Once I run the Ant task, I get “Error: Type was not found or was not a compile-time constant.” Where can I add this additional source path? Also, would I run into the same issue from importing assets from within a SWC? Thanks.
Steve
@Steve great questions.
You can have multiple source directories by duplicating the following line in the -compile target:
You can also have multiple library directories by duplicating the following line in the same target:
Though I would recommend simplifying your application structure by including the different source directories all in one directory. Just in different packages.
[...] 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 [...]
[...] 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 [...]
[...] Android Mobile Development [...]
Hi Jonathan,
If I have external assets for my app, does your ANT file package them into the final .apk file?
Thanks for the great work.
@Jono
By default it will package anything in the “assets” folder. Feel free to make changes to that.
[...] More: Android Mobile Development | UnitedMindset [...]
[...] This post was mentioned on Twitter by Mark Piller, Alexandre Madurell. Alexandre Madurell said: Jonathan Campos and AIR for Android with ANT http://icio.us/llco7Z [...]
hi Jon,
thanks for the ant file and tutorial.
Normally I’m using a swc file that I point my project to, which holds assets i want to use.
But when running the project as an ant build, I get the wellknown compile constant unfound error, in this case:
Error: Type was not found or was not a compile-time constant: swcButton
can I use swc files and how?
thanks,
Jeff.
ah, a successful build is being made when I move the swc into the libs folder you included
.
@Jeff Glad you got it. I’m just getting to a computer and was going to ask where you put the swc.
You can have the swc in some other directory also, you just need to point to it in your ant code.
Hi Jonathan,
Great post, i have a problem, how embed arabic font in AIR for Android?I have try but its not change the font family, can you please share?
Thank