I’m completely new to Java. Now, by tutorials, I’m trying to use the Socket.io library (I’m using Android Studio). I added the library via Project Structure to Dependencies and imported classes in the project itself.

import io.socket.client.IO; import io.socket.client.Socket; public class LoginActivity extends AppCompatActivity { private Socket mSocket ; mSocket = IO.Socket('Localhost:8080') 

But on the last line, the error "Cannot resolve symbol 'Socket'

Why can this happen?

  • if I write IO.socket with a small letter, there is still an error) - EvillNooB

2 answers 2

Single quotes for double replace

  • did not help, just when I start writing IO. just doesn’t just offer a socket as if it isn’t - EvillNooB

I understood my mistake)

  private Socket mSocket; { try { mSocket = IO.socket("http://192.168.100.3:8080"); } catch (URISyntaxException e) {} }; 

Instead

 private Socket mSocket ; mSocket = IO.Socket('http://Localhost:8080')