mkuklis / phonegap-websocket

Websocket PhoneGap plugin for Android
203 stars 78 forks source link

Error "has no method 'exec' at file:///android_asset/www/js/phonegap-websocket.js:11" #12

Closed nobodyjoh closed 10 years ago

nobodyjoh commented 10 years ago

Hi, I search since Monday but impossible to find what is the error, i use phonegap 2.9.0 so i put your differents file in my project but i have this error and i don't understand.

My html file :

<!DOCTYPE HTML>
<html>
<head>
<title>Cordova</title>
<script type="text/javascript" charset="utf-8" src="./js/cordova.js"></script>
<script src="./js/phonegap-websocket.js"></script>
</head>
<body>
</body>
<script type="text/javascript" charset="utf-8">
// new socket
var socket = new WebSocket('ws://10.185.104.110:8080');
</script>
</html>

I put java_websocket.jar on /libs/ and add to build path

And finaly i put two file CordovaClient.java and WebSocket.java on src

My MainActivity :

package com.example.phonegap;

import android.os.Bundle;
import org.apache.cordova.DroidGap;

public class MainActivity extends DroidGap {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }

}

And i put this on confil.xml

    <!-- Deprecated plugins element. Remove in 3.0 -->
      <plugin name="WebSocket" value="com.phonegap.plugins.websocket.WebSocket" />

If you have an idea :)

Thanks

mkuklis commented 10 years ago

@djdelarue current master branch is a work in progress for PhoneGap 3.0. If you want to use it with PhoneGap 2.9.0 please use https://github.com/mkuklis/phonegap-websocket/tree/phonegap-2.x.x branch

nobodyjoh commented 10 years ago

Yes i know i use this branch tust's why i don't understand

mkuklis commented 10 years ago

@djdelarue oh I see. Please make sure cordova.js is being included in your html file.

nobodyjoh commented 10 years ago

Yes it is. When i look with firebug i see cordova.js and cordova_plugins.js. however i can't look cordova_plugins content, there are only cordova content i can read

mkuklis commented 10 years ago

That's strange. I'm not really sure why you are getting this exception. Perhaps 2.9.0 changed its API. Can you try with a lower version (2.8.x). Also here is a repo with demo based on this plugin: https://bitbucket.org/mkuklis/phonegap-websocket-demo

nobodyjoh commented 10 years ago

Hi i'm be back, i try with phonegap 2.8.0 and it works with emulator but on my Htc One i have the same error, even if i use a Nexus 4 (same smartphone on emulator). It's really curious :/

mkuklis commented 10 years ago

@djdelarue I fixed a couple of things on the master branch for PhoneGap 3.x.x. There is also a demo setup based on node.js here: https://bitbucket.org/mkuklis/phonegap-websocket-demo Please give it a try with the PhoneGap >= 3.x.x