Comments (19)
compile ('io.socket:engine.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
its work for me
from socket.io-client-java.
I'm not sure, but it can be the following:
http://stackoverflow.com/questions/14765910/could-not-find-class-xxx-referenced-from-method-xxx-yyy
Or please let met know the details (logs, the version of android you use, how you installed the library).
from socket.io-client-java.
I am getting the same error.
Steps that i followed are:-
- Download engine.io-client and socket.io-client jars from maven repository.
- Included them in the libs folder of my project.
- Project showing these jars in android private libraries which is ticked for use in java build path.
- Android target version is 18 min sdk is 8.
code i am using is
try {
socket = IO.socket("http://192.168.1.3:3000/");
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
socket.emit("foo", "hi");
socket.disconnect();
}
}).on("event", new Emitter.Listener() {
@Override
public void call(Object... args) {}
}).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {}
});
socket.connect();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
log says
06-11 16:09:23.912: W/dalvikvm(16631): VFY: unable to find class referenced in signature (Lorg/java_websocket/client/WebSocketClient;)
06-11 16:09:23.912: I/dalvikvm(16631): Could not find method org.java_websocket.client.WebSocketClient.close, referenced from method com.github.nkzawa.engineio.client.transports.WebSocket.doClose
06-11 16:09:23.912: W/dalvikvm(16631): VFY: unable to resolve virtual method 8794: Lorg/java_websocket/client/WebSocketClient;.close ()V
06-11 16:09:23.912: D/dalvikvm(16631): VFY: replacing opcode 0x6e at 0x0006
06-11 16:09:23.922: W/dalvikvm(16631): Unable to resolve superclass of Lcom/github/nkzawa/engineio/client/transports/WebSocket$1; (1449)
06-11 16:09:23.922: W/dalvikvm(16631): Link of class 'Lcom/github/nkzawa/engineio/client/transports/WebSocket$1;' failed
06-11 16:09:23.922: E/dalvikvm(16631): Could not find class 'com.github.nkzawa.engineio.client.transports.WebSocket$1', referenced from method com.github.nkzawa.engineio.client.transports.WebSocket.doOpen
06-11 16:09:23.922: W/dalvikvm(16631): VFY: unable to resolve new-instance 888 (Lcom/github/nkzawa/engineio/client/transports/WebSocket$1;) in Lcom/github/nkzawa/engineio/client/transports/WebSocket;
06-11 16:09:23.922: D/dalvikvm(16631): VFY: replacing opcode 0x22 at 0x001a
06-11 16:09:23.932: D/dalvikvm(16631): DexOpt: unable to opt direct call 0x225e at 0x27 in Lcom/github/nkzawa/engineio/client/transports/WebSocket;.doOpen
06-11 16:09:23.932: W/dalvikvm(16631): Unable to resolve superclass of Lcom/github/nkzawa/engineio/client/transports/WebSocket$1; (1449)
06-11 16:09:23.932: W/dalvikvm(16631): Link of class 'Lcom/github/nkzawa/engineio/client/transports/WebSocket$1;' failed
06-11 16:09:23.932: D/dalvikvm(16631): DexOpt: unable to opt direct call 0x16d8 at 0x2c in Lcom/github/nkzawa/engineio/client/transports/WebSocket;.doOpen
06-11 16:09:23.982: D/dalvikvm(16631): GC_CONCURRENT freed 228K, 13% free 9536K/10951K, paused 7ms+32ms, total 96ms
06-11 16:09:23.992: W/dalvikvm(16631): threadid=11: thread exiting with uncaught exception (group=0x411272a0)
06-11 16:09:24.012: E/AndroidRuntime(16631): FATAL EXCEPTION: Thread-1259
06-11 16:09:24.012: E/AndroidRuntime(16631): java.lang.NoClassDefFoundError: com.github.nkzawa.engineio.client.transports.WebSocket$1
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.transports.WebSocket.doOpen(WebSocket.java:40)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.Transport$1.run(Transport.java:70)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.thread.EventThread.exec(EventThread.java:45)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.Transport.open(Transport.java:65)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.Socket.probe(Socket.java:411)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.Socket.onOpen(Socket.java:424)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.Socket.onHandshake(Socket.java:460)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.Socket.onPacket(Socket.java:437)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.Socket.access$800(Socket.java:25)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.Socket$5.call(Socket.java:251)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.emitter.Emitter.emit(Emitter.java:119)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.Transport.onPacket(Transport.java:118)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.transports.Polling.access$700(Polling.java:15)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.transports.Polling$2.call(Polling.java:122)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.parser.Parser.decodePayload(Parser.java:222)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.transports.Polling._onData(Polling.java:132)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.transports.Polling.onData(Polling.java:104)
06-11 16:09:24.012: E/AndroidRuntime(16631): at com.github.nkzawa.engineio.client.transports.PollingXHR$5$1.run(PollingXHR.java:112)
06-11 16:09:24.012: E/AndroidRuntime(16631): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
06-11 16:09:24.012: E/AndroidRuntime(16631): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
06-11 16:09:24.012: E/AndroidRuntime(16631): at java.lang.Thread.run(Thread.java:856)
from socket.io-client-java.
Mi issue happen like VaibhavAjayGupta but with java 7 and android sdk 19.
I had to downgrade the socket.io version in server from 1.0 to 0.9 and use another java client API.
from socket.io-client-java.
@VaibhavAjayGupta Did you install org.java-websocke
engine.io-client.java depends on?
from socket.io-client-java.
I've also installed the engine.io-client.jar dependency but don't run because "'Lcom/github/nkzawa/engineio/client/transports/WebSocket$1;' not found. Is strange because my source runs OK in a stand-alone java application.
from socket.io-client-java.
After downloading all the dependency jars i am not getting the above errors but now i am getting this error
Could not find method org.json.JSONArray.remove, referenced from method com.github.nkzawa.socketio.client.Socket$4.run
from socket.io-client-java.
@nkzawa thanks for the library. Awesome library 👍
Although it still shows the warning
Could not find method org.json.JSONArray.remove, referenced from method com.github.nkzawa.socketio.client.Socket$4.run
@juanmiguelRuaDev
At last got it working
jars required are:-
- socket.io-client-0.1.1(http://search.maven.org/remotecontent?filepath=com/github/nkzawa/socket.io-client/0.1.1/socket.io-client-0.1.1.jar)
- engine.io-client-0.2.1(http://search.maven.org/remotecontent?filepath=com/github/nkzawa/engine.io-client/0.2.1/engine.io-client-0.2.1.jar)
- WebSocket-1.3.0(http://search.maven.org/remotecontent?filepath=org/java-websocket/Java-WebSocket/1.3.0/Java-WebSocket-1.3.0.jar)
from socket.io-client-java.
I will fix JSONArray.remove
issue, but please wait for a while. I'm a bit busy recently :(
from socket.io-client-java.
sure
from socket.io-client-java.
Thank you very much @nkzawa and @VaibhavAjayGupta!. When I've time, I'll upgrade my current socket.io version in other branch.
from socket.io-client-java.
@nkzawa This issue also affects on me. Thank you! Waiting for a fix.
from socket.io-client-java.
@VaibhavAjayGupta suggestion of adding the lib got mine fixed. Thank you! And thank you @nkzawa
from socket.io-client-java.
This is the copy of my logcat:
07-06 16:13:55.767: E/AndroidRuntime(9040): FATAL EXCEPTION: Thread-900
07-06 16:13:55.767: E/AndroidRuntime(9040): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
07-06 16:13:55.767: E/AndroidRuntime(9040): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6818)
07-06 16:13:55.767: E/AndroidRuntime(9040): at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1080)
07-06 16:13:55.767: E/AndroidRuntime(9040): at android.view.View.requestLayout(View.java:16775)
07-06 16:13:55.767: E/AndroidRuntime(9040): at android.view.View.requestLayout(View.java:16775)
07-06 16:13:55.767: E/AndroidRuntime(9040): at android.view.View.requestLayout(View.java:16775)
07-06 16:13:55.767: E/AndroidRuntime(9040): at android.view.View.requestLayout(View.java:16775)
07-06 16:13:55.767: E/AndroidRuntime(9040): at android.view.View.requestLayout(View.java:16775)
07-06 16:13:55.767: E/AndroidRuntime(9040): at android.widget.TextView.checkForRelayout(TextView.java:7660)
07-06 16:13:55.767: E/AndroidRuntime(9040): at android.widget.TextView.setText(TextView.java:4446)
07-06 16:13:55.767: E/AndroidRuntime(9040): at android.widget.TextView.setText(TextView.java:4283)
07-06 16:13:55.767: E/AndroidRuntime(9040): at android.widget.TextView.setText(TextView.java:4258)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.christiandrago.syncronization.MainActivity$DownloadWebpageTask$1.call(MainActivity.java:180)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.emitter.Emitter.emit(Emitter.java:119)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Socket.access$701(Socket.java:17)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Socket$4.run(Socket.java:142)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.thread.EventThread.exec(EventThread.java:45)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Socket.emit(Socket.java:138)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Socket.onconnect(Socket.java:303)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Socket.onpacket(Socket.java:230)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Socket.access$400(Socket.java:17)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Socket$2$1$3.call(Socket.java:90)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.emitter.Emitter.emit(Emitter.java:119)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Manager.ondecoded(Manager.java:320)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Manager.access$1100(Manager.java:20)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Manager$3.call(Manager.java:294)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.emitter.Emitter.emit(Emitter.java:119)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.parser.Parser$Decoder.add(Parser.java:156)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Manager.ondata(Manager.java:312)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Manager.access$900(Manager.java:20)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.socketio.client.Manager$2.call(Manager.java:285)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.emitter.Emitter.emit(Emitter.java:119)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.engineio.client.Socket.onPacket(Socket.java:445)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.engineio.client.Socket.access$800(Socket.java:25)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.engineio.client.Socket$5.call(Socket.java:251)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.emitter.Emitter.emit(Emitter.java:119)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.engineio.client.Transport.onPacket(Transport.java:118)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.engineio.client.transports.Polling.access$700(Polling.java:15)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.engineio.client.transports.Polling$2.call(Polling.java:122)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.engineio.parser.Parser.decodePayload(Parser.java:222)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.engineio.client.transports.Polling._onData(Polling.java:132)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.engineio.client.transports.Polling.onData(Polling.java:104)
07-06 16:13:55.767: E/AndroidRuntime(9040): at com.github.nkzawa.engineio.client.transports.PollingXHR$5$1.run(PollingXHR.java:112)
07-06 16:13:55.767: E/AndroidRuntime(9040): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-06 16:13:55.767: E/AndroidRuntime(9040): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-06 16:13:55.767: E/AndroidRuntime(9040): at java.lang.Thread.run(Thread.java:841)
This is the code for the android application:
private class DownloadWebpageTask extends AsyncTask<String, String, String> {
@OverRide
//returns true if the tile was correctly downloaded
protected String doInBackground(String... urls) {
try {
socket = IO.socket("http://192.168.2.200:8080");
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
//socket.emit("foo", "hi");
logTV.setText("CONNECTED");
// socket.disconnect();
}
}).on("event", new Emitter.Listener() {
@Override
public void call(Object... args) {}
}).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {}
});
socket.connect();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "ciao";
}
and this is the code at server side:
// NODEJS SERVER WORKING
var http = require('http');
//set up the server
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
});
//start server 130.237.238.191
//server.listen(8081, "192.168.1.42");
server.listen(8080, "192.168.2.200");
//bind the socket to the server
var io = require('socket.io')(server);
//var fs = require('fs');
//var io = require('socket.io').listen(8001);
io.sockets.on('connection', function (socket) {
console.log("android client connected at server side...");
//socket.emit('connected', "connection established");
/*socket.on('request', function (data) {
console.log(data);
socket.emit('response', {server: data['client']});
//fs.writeFile("c:/output.dat", data['client'], function(err) {
// if(err) {
// console.log(err);
// } //else {
//console.log("The client data was saved!");
//}
//});
});*/
});
console.log('Server running');
I tried both the solution with and without AsyncTask and they gave me both the same errors.
Could anyone help me?
from socket.io-client-java.
@dragochristian Your error is pretty explicit: "Only the original thread that created a view hierarchy can touch its views."
The line: "logTV.setText("CONNECTED");" Cannot be called from a doInBackground thread. You should probably use the Handler class for that.
Read the Android docs on AsyncTask to learn why.
EDIT: btw, this is not related to socket.io. If unsure: StackOverflow.
from socket.io-client-java.
I forgot to remove it after I copy and paste in the async task!
Thanks!!!
from socket.io-client-java.
fixed #10
from socket.io-client-java.
Just thought I'd mention that I'm clueless about why this issue ("Could not find method org.java_websocket.client.WebSocketClient., referenced from method com.github.nkzawa.engineio.client.transports.WebSocket$1.") happens.
I'm trying to solve it in a different way though so I can successfully debug the whole project (including socket.io-client, engine.io-client and Java-WebSocket library code) in Eclipse.
I have imported the projects into the IDE and followed http://stackoverflow.com/questions/14765910/could-not-find-class-xxx-referenced-from-method-xxx-yyy for each of them (i.e. added the generated target jar file to the project's Build Path, selected the file in the Order and Export tab and moved it to the top of the list).
It works for the first two projects but for Java-WebSocket it doesn't work. It only worked after I downloaded and included http://search.maven.org/remotecontent?filepath=org/java-websocket/Java-WebSocket/1.3.0/Java-WebSocket-1.3.0.jar in the libs folder as @VaibhavAjayGupta mentioned.
If anyone has an idea about what is going on, please let us know.
from socket.io-client-java.
Can you tell me steps to do WebSocket connection ....
from socket.io-client-java.
Related Issues (20)
- socket.io client sometimes sends arrays wrong HOT 5
- can i use multiple socket connection ?
- Android 13 not available HOT 1
- It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible HOT 3
- sendBuffer should be accessible
- Getting EVENT_CONNECT_ERROR from Android to Node HOT 1
- Change/update auth or query or extraheaders containing token after connection HOT 1
- Is this project Still Alive? HOT 3
- How to listen to Manager events? (Socket events are working) HOT 2
- Straightforward logging option for Android
- testDecodeError function in Helpers.java error message clean up HOT 2
- Report: ConcurrentModificationException when use AckWithTimout... HOT 2
- Connection state recovery HOT 1
- NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference HOT 1
- Unable to emit JSON object instead it is emitting Stringified Json in Client Version - 1.0.2 HOT 2
- Implement Connection State Recovery
- it throws java.lang.ClassCastException when sending nested json data. HOT 1
- in the this one the depencies are not dwonloading for me
- Android 14 not compatible with version 2.1.0
- received disconnect event. and socket closed.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socket.io-client-java.