Deploying a Worklight app onto the Android Emulato

2019-08-28 09:36发布

问题:

I'm trying to deploy an application to Android by using Worklight.

I've seen a similar error to this posted before, however there weren't any concrete answers given. The error is triggered when I launch the app on an Android emulator, this is it:

08-13 08:22:26.262: E/Web Console(347): TypeError: Result of expression 'cordova.exec' undefined is not a function. at file:///data/data/com.Test/files/www/default/wlclient/js/wlgap.android.js:697

Now, I believe this js file is injected at run time, and therefore I'm not sure how and where I edit it.

A later error thrown is this:

08-13 08:22:30.982: E/Web Console(347): TypeError: Result of expression 'h.body()' undefined is not an object. at file:///data/data/com.Test/files/www/default/dojo/mobile-ui-layer.js:257

So the problem lies with Dojo and/or Cordova-PhoneGap. The question is, how do I get around it and get my app working?

I believe it may be a problem with the wlCommonInit in that it cannot have anything before this is called, however, I am parsing Dojo before it hits this. If I don't parse Dojo before it hits this, I get loads of Dojo parsing errors.

Any help is truly appreciated.

Thanks!

回答1:

You can see wlgap.android.js in the android native project. You should put your Dojo code inside the wlCommonInit (or the wlEnvInit) and you do not need to check if dom or device are ready (the processes run by Worklight test it before firing the wlCommonInit).



回答2:

Make sure all your Dojo parsing is done in wlCommonInit - that means setting parsing on load to false and doing it programmatically in wlCommonInit.