Well, I am writing an Android application, and I want to use the Socket.IO-Client for Java , written by Gottox. The documentation on github says the library is compatible with Android.
Now my question is somewhat basic. How to use this library in an Android app?
So far I have tried two methods.
I built this library's jar file using commands (as explained in the doc library)
cd $PATH_TO_SOCKETIO_JAVA ant jar ls jar/socketio.jar
I have a nice banner library in a folder. I added that jar for my project using
RIGHT_CLICK->Properties->Java Build Path->Add External Jars
Then I connected using
SocketIO socket = new SocketIO("http://"+ip+":"+port+"/");
I was able to compile and create the application without any errors. But when I run, I got an exception in the line that I posted above.
java.lang.NoClassDefFoundError: io.socket.SocketIO at com.research.socketioresearch.LoginActivity.connectToSocketIO(LoginActivity.java:122) at com.research.socketioresearch.LoginActivity$1.handleMessage(LoginActivity.java:113)
As a second attempt, I created a java project using socket.io library source code in my eclipse. Then I exported this project as a jar using
RIGHT_CLICK->export->java->Jar File
Then I added this jar file to my original android project, using the same way as I tried in method 1 (Add external banks). This time, I was also able to compile and build, but get the same exception in a single line of code.
Now who has success in using the same library in Android? How it's done?
source share