0

I am testing developing a Hybrid application in MobileFirst Studio and want to connect to MobileFirst Server during the app init. I updated main.js file under MF_Project/app/[appNanme]/common/js/main.js init method with the following:

WL.Client.connect({
  onSuccess: function() {
    WL.Logger.info("onSuccess: connection success");
  },
  onFailure: function(err) {
    WL.Logger.info("onFailure: Exception: " + err);
  }
});

I then build the app for Android environment (right click the appName the one under MF_Project and select "Build for Android environment"). Then I ran the app as Android Application in emulator, but the log comes back with error

01-25 16:04:29.364: E/NONE(2755): Invalid invocation of method WL.Client.connect; Invalid value 'undefined' (undefined), expected type 'function'.
01-25 16:04:29.368: E/NONE(2755): Invalid invocation of method WL.Client.connect; Invalid options attribute 'onSuccess'. Invalid invocation of method WL.Client.connect; Invalid value 'undefined' (undefined), expected type 'function'.

Any insight on this would be appreciated.

Andi Setiyadi
  • 197
  • 1
  • 1
  • 11

1 Answers1

0

I have tested the supplied project in MFP 6.3 using a Nexus 5 device running Android 5.0.1.

The application successfully connected to the MFP Server.
In the log I saw the SUCCESSFUL: [object object] message.

[object object] because you did not JSON.stringify the result.
For example: WL.Logger.info("SUCCESSFUL: " + JSON.stringify(response));

I think something is wrong with your generated AVD - try to create a new one, in addition to testing in an actual device.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • Idan .. thank you for your input. I tried changing the AVD to Nexus 5 with 5.x (API 21) and it works .. a bit head scratching since I intentionally build the android app using API 19 which should work with the AVD 4.x, but apparently not. As of now I can live with 5.x. – Andi Setiyadi Jan 27 '15 at 02:05