Workaround for PPSChannel error when running QNX PlayBook specific APIs on the Desktop

Posted on February 4, 2011 | 8 comments

First thing is to note this is a workaround and might not work in the future or might not cover all the errors you might see. Take the simple use case of creating an AIR application for PlayBook and with a qnx.ui.text.TextInput component in the display list. Because the qnx.ui.text.TextInput class allows you to define which PlayBook KeyboardType is shown on the device it must call out to a PlayBook specific AIR API. If you try and run this application on the desktop you will see this error:

qnx.pps.PPSChannel Error Message

This error is because the AIR runtime on the desktop does not have a qnx.pps.PPSChannel class, this class is specific to the PlayBook version of the AIR runtime that RIM has extended in their BlackBerry Tablet OS.

Ok, so what if you still want to run it on the desktop to work on UI layout an not necessarily full functionality?

This is the workaround to do just that, and again this might not work for all PlayBook specific API’s and for sure some features of QNX UI components might not work correctly. But its useful for UI design work without having to publish out to the simulator a bunch of times.

We’ll be working with this ActionScript based PlayBook application that just adds a qnx.ui.text.TextInput to the display list.

package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;

import qnx.ui.text.TextInput;

public class PPSChannelTest extends Sprite
{
    public function PPSChannelTest()
    {
        super();
        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.NO_SCALE;
       
        var input:TextInput = new TextInput();
        addChild(input);
    }
}
}

First thing to do is in your Flash Builder project go into Project -> Properties -> Build Path. And change the qnx-air.swc to be “merged into code” instead of “external”. See the images below:

Link Type Setting for qnx-air.swc

Link Type dialog change to 'Merged into code'

Now that the classes are merged into the application SWF we can monkey patch the qnx.pps.PPSChannel class. To do this go to New -> Package and fill with “qnx.pps” as seen below:

Add qnx.pps package

The next step is to create an ActionScript file by going to New -> ActionScript File. You can’t create a New -> ActionScript Class because the dialog will error out saying the class is already there in qnx-air.swc. So create a new ActionScript blank file in the qnx.pps package folder and call it PPSChannel. Then open up the file and copy this code into it:

package qnx.pps
{
public class PPSChannel
{
    public function PPSChannel()
    {
    }
}
}

Now save the files and project make sure it does a new compile and run it on the desktop. You should be able to see the qnx.ui.text.TextInput box on the desktop.

The application running on the desktop

  • Pingback: Tweets that mention @renaun posts: Workaround for PPSChannel error when running QNX PlayBook specific APIs on the Desktop -- Topsy.com

  • http://iqandreas.blogspot.com/ Andreas Renberg

    I seem to be getting an error from that “VerifyError: Error #1079: Native methods are not allowed in loaded code.”

    Setting SWC back to “External” fixes the error, but brings back the “PPS Channel could not be found” runtime error.

    Any ideas?

    • http://www.renaun.com Renaun Erickson

      I did see that a couple of times. Try cleaning building your project, or removing the qnx.pps.PPSChannel class file and putting it back in there. Or just change the main application file a little bit and have it recompile. I couldn’t find a one sure way but the error showed up a couple times and some form of re-compiling worked for me. Thanks for trying it out.

  • http://www.patrick-heinzelmann.de Patrick Heinzelmann

    Additionally to the solution of Monkey Patching of QNX PPSChannel, I found a second solution when using the Playbook specific APIs (AudioManager, MediaServiceConnection, Device, QNXApplication).

    Check my blog post: http://www.patrick-heinzelmann.de/blog/2011/02/05/playbook-development-with-device-specific-libraries-using-qnx-pps-and-why-is-adl-throwing-errors/

  • Pingback: Working with PlayBook QNX UI components : Mihai Corlan

  • Pingback: Working with PlayBook QNX UI components (Adobe Flash Platform Blog)

  • Pingback: Cool Stuff with the Flash Platform – 2/10/11 | Finding Out About

  • Pingback: @renaun posts: PlayBook QNXApplication SWIPE_DOWN in a multi platform SWF

  • Kate

    Thanks for the solution but it still cannot help. The first error message gone but now I have a little bit different one “ReferenceError: Error #1069: Property addEventListener not found on qnx.pps.PPSChannel and there is no default value.”
    What could you suggest?
    Thanks

    • http://www.renaun.com Renaun Erickson

      what code are you using to get this error? Looks like the temporary PPSChannel needs to act like it has an addEventListener method.

  • Kate

    Hello,
    the call stack after call in my dialog is here:

    ReferenceError: Error #1069: Property addEventListener not found on qnx.pps.PPSChannel and there is no default value.
    at qnx.dialog::DialogInterface/open()[E:\hudson\workspace\SDK092_deckard_sdk\src\screen\src\qnx\dialog\DialogInterface.as:114]
    at qnx.dialog::DialogInterface()[E:\hudson\workspace\SDK092_deckard_sdk\src\screen\src\qnx\dialog\DialogInterface.as:99]
    at qnx.dialog::DialogInterface$/getInstance()[E:\hudson\workspace\SDK092_deckard_sdk\src\screen\src\qnx\dialog\DialogInterface.as:67]
    at qnx.dialog::BaseDialog/show()[E:\hudson\workspace\SDK092_deckard_sdk\src\screen\src\qnx\dialog\BaseDialog.as:345]

    The code that rising this exception is:
    var myDialog:AlertDialog = new AlertDialog();

    myDialog.show();

  • Chris

    Hi Renaun, what would the process be to fix this issue in Flash Pro CS5? Thanks.

    • http://www.renaun.com Renaun Erickson

      Probably similar by adding this fake PPSChannel class into your class path. Might be classpath ordering issues but i would give that a try.