Debugging Flex/AIR Applications on an Android Device

Tuesday, November 23, 2010

At RIAUnleashed 2010, I attended a lab titled "Building your first Android application using Flex and AIR". One of the first things you'll want to do is see your "Hello World" app running on a device, and not just the emulator. On Mac and Linux, you shouldn't need to do anything special. On Windows, however, you'll need to do some work.

Note: This assumes you have Flash Builder Burrito installed. If not, you can get it at In addition, I’m using a Droid 2, which is a supported device.

Note 2: You need wifi. Though you’ll be using USB to deploy the app to the device, the actual “debugging” happens over wireless. If you don’t have wifi, you can still run the app on the device, but you won’t be able to set breakpoints in your code, etc.

First, if you're new to Android, and you haven't yet attempted to connect your device to your PC yet, there's one small but important thing you'll need to do, and it appears that it does not do this by default, leading to potentially a lot of time and frustration.

I had two different installation experiences on two different machines. On a Windows 7 AMD64bit laptop, installing the Android drivers for the Droid 2 worked exactly as described in the Adobe docs. However, on a Windows 7 IBM 64bit PC, I had no luck installing the drivers manually. To finally get the Droid 2 installed properly, I did the following:

  1. Connect via usb (duh)
  2. slide the notification panel down and select "USB Connection".
  3. It will give you several options, and probably defaults to "Charge Only". Change this to "PC Mode", and then it'll install the appropriate drivers from the web. If you connect the device with “Charge Only”, you’ll bang your head against the wall trying to figure out why Flash Builder can’t connect.

This should be all you need to get FB to recognize your device. Now, you’ll need to change some settings on the device to “open it up”, namely enabling USB debugging.

  1. On your droid, go to Settings
  2. Choose Applications –> Development
  3. Enable USB Debugging

Now, back in FlashBuilder, do the following. This assumes you have a Mobile project:

  1. Right click either in the editor of your “main” file or in the package explorer
  2. Select “Debug As”, and then “Debug Configurations”. You can also choose “Run As” to run it, though it won’t be in debug mode.
  3. Select “Mobile Application”, and then  click the “New” icon.
  4. Give it a name, like “My App on Droid 2”
  5. In “launch method”, choose “on device”, and then hit “run”
  6. This should pop up a grid with connected devices, and your device should be in there.

Note: on the PC, it took about a minute after installing the drivers before FlashBuilder would recognize it as a connected device. In fact, I changed it from Charging to PC mode several times, and then finally it showed up in the grid.

Finally, after getting the drivers installed (if you’re on Windows), correctly setting the Droid to enable USB debugging, and configuring a FlashBuilder run configuration, you should be all set for debugging on your device. If you still can’t debug, it might be due to being on a VPN, or also due to firewall settings. You’ll need to correctly configure your firewall and perhaps your wireless router to enable the communication between your dev machine and your Android device.

1 comment:

Alin said...

This site is nice and amazing. I love your post! It's also nice to see someone who does a lot of research and has a great knack for ting, which is pretty rare from bloggers these days.