cordova.exec causing problems in my Android projec

2019-09-12 20:51发布

问题:

I have a Worklight project (a hybrid app) that I'm trying to deploy to Android. At the moment, it has a cordova plugin which is uses for PhoneGap stuff. My project isn't currently using the cordova plugin, but there are hundreds of calls to it so I guess it needs to be present either way (it's packaged in this way by worklight and so I'm not particularly well informed about how it operates).

My problem is that the Android emulator is constantly throwing the same sort of problem when it runs the project as below:

06-13 14:20:57.385: E/Web Console(795): Uncaught TypeError: Object # has no method 'exec' at file:///data/data/com.Test/files/www/default/wlclient/js/wlgap.android.js:697

If it isn't that exact error, it's a similar error which complains about cordova in one way or another. I have JS files that are littered with cordova.exec calls and I think this is where it's failing as it cannot find that method. I'm using cordova 1.6.1 that is defined as cordova.js as part of my Android project.

I'm not really sure how else to define my problem as I'm at a loss as to where to start to get it to play ball. Any suggestions are welcome. If you require further explanation of my issue, let me know.

回答1:

What version of Worklight are you using? Do you have your android application the cordova.js file?

{YOUR_PROJECT}\apps{YOUR_APPLICATION}\android\native\assets\www\default\wlclient\js\cordova.js

and

{YOUR_PROJECT}\apps{YOUR_APPLICATION}\android\native\libs\cordova.jar and

{YOUR_PROJECT}\apps{YOUR_APPLICATION}\android\native\libs\worklight-android.jar

If you have no native code in the Android environnement, delete the native folder {YOUR_PROJECT}\apps{YOUR_APPLICATION}\android\native

and build the application again.