Wednesday, May 4, 2011

How To: Use Flex 4.5 with AIR 2.5 on the BlackBerry PlayBook

As you might already know, the BlackBerry PlayBook from RIM will initially be shipping with AIR 2.5, not AIR 2.6 (this is to come later in an update to the device). Flex 4.5 SDK requires AIR 2.6 as the minimum supported runtime – this is because of specific feature support (such as soft keyboard) as well as bug fixes/performance improvements. We know however that a lot of you are eager to develop Flex 4.5 applications for BlackBerry Tablet OS, so I’d like to share an unsupported workaround that you can use in the meantime.

I’ve created a playbook_overrides.swc that monkey patches the release build of the Flex 4.5 SDK to remove all AIR 2.6 dependencies. This allows you to publish a Flex 4.5 application that targets AIR 2.5. Here are some instructions to get you started. Again, keep in mind that this is an unsupported hack until (1) AIR 2.6 is available on the PlayBook and (2) Flex and Flash Builder update to 4.5.x in June 2011.

Requirements

  • Flash Builder 4.5
  • BlackBerry Tablet SDK and Plugin 1.0.1
  • playbook_overrides.zip (Contains playbook_overrides.fxpl, playbook_overrides.swc and TwitterTrendsFinal.fxp example project)

Steps

  1. Create a new Flex Mobile project with BlackBerry Tablet OS as a target platform
  2. Add playbook_overrides to the library path. This SWC patches SDK and Mobile Theme classes to remove soft keyboard dependencies. Download: playbook_overrides.zip
  3. Open Project Properties > Flex Compiler
  4. Add “-swf-version=10″ in “Additional compiler arguments”
  5. Open Project Properties > Flex Build Packaging > BlackBerry Tablet OS > Advanced tab.
  6. Add “-forceAirVersion 2.5″
  7. Run/Debug to device or emulator

Troubleshooting

  1. Crash on launch (application briefly appears in launcher, then closes).
    Make sure -swf-version=10 is set in additional compiler arguments.
  2. Blank or stuck on splash screen on launch
    Usually indicates a runtime error. Could indicate an AIR 2.6 dependency VerifyError.

Next Steps

  • Refactor your project into 2 projects to target Android with AIR 2.6 support and BlackBerry Tablet OS with AIR 2.5 support simultaneously
  • Use the BlackBerry Tablet SDK for native controls in your Flex Mobile project
  • Try the TwitterTrendsFinal.fxp in the playbook_overrides.zip. This FXP already links playbook_overrides.swc and is ready to deploy. All it needs is an update to blackberry-tablet.xml to add the and of your debug token to deploy to a PlayBook.

No comments: