How to solve “Native methods are not allowed in lo

2019-08-10 07:31发布

问题:

I want to let my app to run sound while the playbook in standby mode, I put this statement in the start up

QNXSystem.system.inactivePowerMode = QNXSystemPowerMode.THROTTLED;

Now when I debug the app on the simulator (not desktop debugger) I got this error

VerifyError: Error #1079: Native methods are not allowed in loaded code.

And this error I got also when using AlertDialog.

Note: I am using Flash builder, and I have put the qnx SWC in the libraries path. .... so to solve these problems?

回答1:

To allow code compiled w/native extensions to run on the simulator, we had to put code that used native extensions in methods that would never get executed (when on the simulator).

It wasn't enough to just wrap the offending code in an if/else block. The if/else needs to call another method that either has the native version or the simulator version of the code.

For example:

private function showNativeOrFlexAlert(message:String):void
{
    // we used the Capabilities class to determine this, might be a better way
    if (isMobile)
        showNativeAlert(message);
    else
        showFlexAlert(message);
}

// have to be careful here, this method signature CANNOT include
// any classes from native extension -- no errors on device, but fails on simulator
private function showNativeAlert(message:String):void
{
    // use native API to show alert
}
private function showFlexAlert(message:String):void
{
    // use the Flex Alert class
}


回答2:

Set the qnx-air.swc linkage to "external".