How to solve “Native methods are not allowed in loaded code” error

北城以北 提交于 2019-12-24 10:47:54

问题


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".



来源:https://stackoverflow.com/questions/10257387/how-to-solve-native-methods-are-not-allowed-in-loaded-code-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!