cordova-plugin-opentok icon indicating copy to clipboard operation
cordova-plugin-opentok copied to clipboard

getting error when connecting to session with opentok 1.0.3 on Intel XDK Cordova Crosswalk Android build

Open tysjiang opened this issue 9 years ago • 20 comments

When trying to connect to a session, this error is popping up: "Attempt to invoke virtual method 'void com.opentok.android.Session.connect(java.lang.String)' on a null object reference"

Steps to reproduce:

  1. built app with Intel XDK v1826 Cordova 4.1.2 Crosswalk (10) Android
  2. try to connect to session session.connect(videoToken, function(){ // session.publish( publisher ); });
  • checked videoToken to make sure it is valid
  • tested with Samsung s5 Lollipop
  • note: same code works on the iOS builds

tysjiang avatar Mar 26 '15 00:03 tysjiang

hmm.. seems like a null videoToken... have you tried using a static token for testing?

byronalfonso avatar Mar 26 '15 09:03 byronalfonso

just tried using a static token but got the same error

the same code works (or at least past this breaking point) with Intel XDK v1826 Cordova 4.1.2 Android builds so I'm thinking it's related to how opentok interop with Crosswalk 10

tysjiang avatar Mar 26 '15 15:03 tysjiang

additional info: This issue will actually happen on iOS builds also if you use brodysoft sqlite 0.7.3 for some reason... So if you have to use sqlite, use 0.7.0, that version works fine with this plugin on iOS.

tysjiang avatar Apr 20 '15 06:04 tysjiang

I have the same issue at this moment with Crosswalk and OpenTok for Android. I am using following versions:

  • cordova-plugin-crosswalk-webview 1.2.0
  • com.tokbox.cordova.opentok 1.0.3
  • ionic-cli 1.5.0
  • cordova-cli 5.0.0
  • ionic-lib 1.0.0

Anyone have the same issues and/or solution? When I remove Crosswalk all is working correct, but when using Crosswalk OpenTok is crashing.

mark-veenstra avatar Jun 15 '15 11:06 mark-veenstra

Same issue here. If I remove crosswalk, it works. With crosswalk, it doesn't work.

MathildeLemee avatar Jul 16 '15 19:07 MathildeLemee

The same issue for me.

gevorgmakaryan avatar Oct 12 '15 16:10 gevorgmakaryan

Has anyone any updates related to this issue?

gevorgmakaryan avatar Oct 12 '15 16:10 gevorgmakaryan

I'm running into this as well. I'm not too familiar with Android development, but managed to pull out this using logcat:

I/OTPlugin(18618): initSession
I/OTPlugin(18618): created new session with data: ["xxxxxxxx","XXXXXXXXXXXXXX"]
I/art     (18618): Rejecting re-init on previously-failed class java.lang.Class<com.opentok.android.Session>
W/System.err(18618): java.lang.UnsatisfiedLinkError: com.opentok.android.Session
W/System.err(18618):    at com.tokbox.cordova.OpenTokAndroidPlugin.execute(OpenTokAndroidPlugin.java:396)
W/System.err(18618):    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:95)
W/System.err(18618):    at org.apache.cordova.PluginManager.exec(PluginManager.java:130)
W/System.err(18618):    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
W/System.err(18618):    at org.crosswalk.engine.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
W/System.err(18618):    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err(18618):    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
W/System.err(18618):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(18618):    at android.os.Looper.loop(Looper.java:145)
W/System.err(18618):    at android.os.HandlerThread.run(HandlerThread.java:61)
I/chromium(18618): [INFO:CONSOLE(10177)] "connecting: XXXXXXXX", source: file:///android_asset/www/cordova_bundle.js (10177)
I/OTPlugin(18618): addEvent
I/OTPlugin(18618): adding new event - sessionEvents
I/OTPlugin(18618): connect
I/OTPlugin(18618): connect command called
E/PluginManager(18618): Uncaught exception from plugin
E/PluginManager(18618): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.opentok.android.Session.connect(java.lang.String)' on a null object reference
E/PluginManager(18618):     at com.tokbox.cordova.OpenTokAndroidPlugin.execute(OpenTokAndroidPlugin.java:433)
E/PluginManager(18618):     at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:95)
E/PluginManager(18618):     at org.apache.cordova.PluginManager.exec(PluginManager.java:130)
E/PluginManager(18618):     at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
E/PluginManager(18618):     at org.crosswalk.engine.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
E/PluginManager(18618):     at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
E/PluginManager(18618):     at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
E/PluginManager(18618):     at android.os.Handler.dispatchMessage(Handler.java:102)
E/PluginManager(18618):     at android.os.Looper.loop(Looper.java:145)
E/PluginManager(18618):     at android.os.HandlerThread.run(HandlerThread.java:61)

EDIT: I found this related post on stackoverflow: http://stackoverflow.com/questions/30843969/opentok-for-cordova-with-crosswalk-throws-alert

IjzerenHein avatar Oct 27 '15 13:10 IjzerenHein

Anyone found a solution to this issue?

silverio avatar Nov 05 '15 20:11 silverio

Maybe this answer helps: http://stackoverflow.com/a/31562610/1800695

mark-veenstra avatar Nov 06 '15 10:11 mark-veenstra

I think we should all be focused on this repository: https://github.com/aoberoi/cordova-plugin-opentokjs But I have created a plugin which uses the old library for iOS and the new library for Android and browser. This way Crosswalk is supported: https://github.com/Mobilea/cordova-plugin-opentok.git#develop

mark-veenstra avatar Nov 12 '15 08:11 mark-veenstra

@mark-veenstra How did you fix the issue that WebRTC cannot be used when your cordova app is loaded over 'file://' ?

IjzerenHein avatar Nov 19 '15 15:11 IjzerenHein

@IjzerenHein Don't open your project by double clicking on index.html. But make sure you serve the page. For example create a gulp task to serve your platform browser:

var webserver = require('gulp-webserver');
gulp.task('browser:serve', function() {
    gulp.src('./platforms/browser/www/')
        .pipe(webserver({
            livereload: {enable: true, port: 35729},
            directoryListing: false,
            host: localhost,
            port: 8100,
            open: true
        }));
});

Make sure to have the NPM module gulp-webserver installed.

mark-veenstra avatar Nov 19 '15 15:11 mark-veenstra

I eventually abandoned the approach trying to get the original OpenTok plugin to work with Crosswalk. Instead, I solved it by taking the following steps:

In your config.xml, add --allow-access-from-files to the xWalkCommandLine preference:

<preference name="xwalkCommandLine" value="--disable-pull-to-refresh-effect --allow-access-from-files" />

Now download a copy of the original OpenTok.js file (http://static.opentok.com/v2/js/opentok.js) and outcomment the following lines:

//if (location.protocol === 'file:') {
//  /*global alert*/
//  alert('You cannot test a page using WebRTC through the file system due to browser ' +
//    'permissions. You must run it over a web server.');
//}

IjzerenHein avatar Nov 19 '15 15:11 IjzerenHein

@IjzerenHein : This plugin does the same as you did manually: https://github.com/Mobilea/cordova-plugin-opentok.git#develop

mark-veenstra avatar Nov 19 '15 15:11 mark-veenstra

@mark-veenstra I tried it, but it didn't work for me. I tried like a 100 hundred things so I'm not sure what went wrong or why I abandoned that approach. I see that it automatically parses and changes the OpenTok.js file, how cool is that, nice :)

Does it also enable --allow-access-from-files ?

IjzerenHein avatar Nov 19 '15 15:11 IjzerenHein

@IjzerenHein : Hmm I am using the same plugin in a project now with CrossWalk on Android. I did install the plugin with cordova/ionic plugin add https://github.com/Mobilea/cordova-plugin-opentok#develop And when building for IOS manually in XCode make sure to set the ENABLE_BITCODE to no

mark-veenstra avatar Nov 19 '15 15:11 mark-veenstra

@mark-veenstra Alright, well I'm gonna have a look at it later. I've made some changes to the original plugin which I need to run my project. I've pushed pull-requests for them to the original repo, but it doesn't seem very active anymore. When I get it up & running using your repo, I'll send the pull requests there, so we can hopefully have a single good repo.

IjzerenHein avatar Nov 19 '15 17:11 IjzerenHein

+1 Is there a "best practice approach" available now for dealing with this? I'm using the OpenTok plugin together with Meteor, and could not even install the app. It crashed on first run.

derwaldgeist avatar Jan 21 '16 13:01 derwaldgeist

Got it running now (was a problem with setting the background color). But I cannot see any videos (neither subscriber nor publisher). It only works without Crosswalk. Any ideas how the videos can be enabled if Crosswalk is included?

derwaldgeist avatar Jan 21 '16 21:01 derwaldgeist