Debug & Deploy Flash on Android

It is now a few weeks after I started experimenting with AIR for Android. While watching all the great tutorials about how to make things work (AIR for Android – Part 1, Part 2) and how to debug application running on device (Debug AIR apps on Android with Flash Builder 4, another in french and Flash), I have decided to attach some of my own findings and practices to build, deploy and debug apps.

To start, it is a good practice to setup your environment variable path to Android sdk and AIR sdk:

PATH: ...;C:/Users/Yoz/Work/Android/SDK/2.2;C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\\bin

Next, the whole certificate thing does not make sense to me because you can/have to create one by yourself. The cert need to be valid for 25 years else Android Market will not accept your application (bye bye real signed certificate from PGP TrustCenter 🙁 )

Debugging with Flash Builder 4 on Emluator

Sadly, I was not able to make emulator to connect my Flash Builder profiler even it should work with as IP addres of your hosting pc, and it seems noone did it work yet.

Once you have your AIR project created and flex SDK changed to one with AIR for Android, and you have created and running Android emulator, you are ready to create some batch (.bat) files in your main project directory (console.bat, emulator.bat, build-debug.bat, install.bat). I am using “onBoard2Android” application, so you have to replace this with your project name:

  1. run console.bat in separate window – shows connected devices / emulators, and if your emulator is listed and ready, continue to see logs from emulator, do not close this one
    adb devices
    adb logcat
  2. run emulator.bat in separate window – shows created devices / emulators and runs the one called “Nexus1” (name it as you wish), once it runs, you may close this window
    adb devices
    emulator.exe -avd Nexus1
  3. make debug .swf in flash builder
  4. run build-debug.bat – creates .apk file from debug .swf, it contains link to your certificate + password (MYPASSWORD, so you do not have to enter it any time you run int), name of .pak file, path to .xml file, path and name of .swf file. You should see “Success” when correctly builded
    adt -package -target apk-debug -storetype pkcs12 -keystore C:/Users/Yoz/Work/certificates/android.p12 -storepass MYPASSWORD onBoard2Android.apk src/onBoard2Android-app.xml -C bin-debug onBoard2Android.swf
  5. run install.bat – installs application on emulator and runs it, contains path to my Android sdk directory… I usualy keep this window opened and run build and install in the same one. I was not able to merge build and install into one .bat file, because it stops after adt command, but if you have more luck, let me know
    adb.exe install -r onBoard2Android.apk
    adt -launchApp -platform android -platformsdk C:/Users/Yoz/Work/Android/SDK/2.2 -appid onBoard2Android
  6. now you should see trace() and exception log in console window.

Export Release Version on Emulator

  1. make sure your emulator connected and running
  2. create release version – .air file
  3. run build.bat – notice apk-emulator
  4. adt -package -target apk-emulator -storetype pkcs12 -keystore C:/Users/Yoz/Work/certificates/android.p12 -storepass MYPASSWORD onBoard2Android.apk onBoard2Android.air icons/36x36.png icons/48x48.png icons/72x72.png
  5. run install.bat

Debugging with Flash Builder on real device

It is recommended to test your application on real device, before you make it public on android market, it runs faster than emulator and the UI need to be tested too. The process is almost the same as to debug with emulator.

  1. run console.bat (use the same in example above)
  2. on your device go to Settings / Applications / Development / USB debugging and turn it on
  3. connect your device to the same network (wifi) as is your hosting PC, and make sure PC IP address as available on the network
  4. turn off firewall on pc (if you have time to detect witch port / service to enable on running one, please let me know)
  5. make debug .swf file
  6. run build-debug.bat – with -connect followed by IP address of your hosting PC
    adt -package -target apk-debug -connect -storetype pkcs12 -keystore C:/Users/Yoz/Work/certificates/android.p12 -storepass MYPASSWORK onBoard2Android.apk src/onBoard2Android-app.xml -C bin-debug onBoard2Android.swf
  7. make a new Web Application debug profile in your flash builder (just follow the screenshots) for your project, and make sure to setup default path to “about:blank”
  8. unlock your phone if sleeping and run install.bat
  9. now when application starts on device it should connect your profiler

Export Release Version on Device

  1. make sure your device connected and running
  2. create release version – .air file
  3. run build.bat – attach icons defined in .xml descriptor
    adt -package -target apk -storetype pkcs12 -keystore C:/Users/Yoz/Work/certificates/android.p12 -storepass MYPASSWORD onBoard2Android.apk onBoard2Android.air icons/36x36.png icons/48x48.png icons/72x72.png
  4. run install.bat
  5. Now you have your release version ready to publish on Android Market.

Where to go from here:

3 comments so far

  1. Paulius Uza December 16, 2010 03:36

    If anyone wants to use adb tool included with Android sdk to install and launch an Adobe AIR applications on a connected testing device, then do the following:

    Installs application from APK (with overwrite):
    adb install -r /Path/To/Your/App.apk

    Launches application Adobe AIR wrapper:
    adb shell am start -a android.intent.action.MAIN -n

    Great blog! Cheers!

  2. Jozef Chúťka December 16, 2010 16:32

    thnx for the code Paulius,
    what exactly does Adobe AIR wrapper means?

  3. […] I have installed Android SDK on a new machine, I have almost forgotten the steps necessary to run AIR application on Android emulator. There has been some changes within android sdk e.g. adb.exe is no longer located in […]

Leave a comment

Please be polite and on topic. Your e-mail will never be published.