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.
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.
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.
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.
#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)]
#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!
## 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.
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.