Importing a module into Android Studio

Just starting in Android dev, I would like to use Android Websockets code in my new project in Android Studio.

OS X 10.8.x, AS 0.4.0

I followed: How to import eclipse library project from github to android studio project?

Everything worked great until I tried to actually code. I pasted in (from the example):

List<BasicNameValuePair> extraHeaders = Arrays.asList(
    new BasicNameValuePair("Cookie", "session=abcd")

WebSocketClient client = new WebSocketClient(URI.create("wss://"), new WebSocketClient.Listener() {
    public void onConnect() {
        Log.d(TAG, "Connected!");

    public void onMessage(String message) {
        Log.d(TAG, String.format("Got string message! %s", message));

    public void onMessage(byte[] data) {
        Log.d(TAG, String.format("Got binary message! %s", toHexString(data)));

    public void onDisconnect(int code, String reason) {
        Log.d(TAG, String.format("Disconnected! Code: %d Reason: %s", code, reason));

    public void onError(Exception error) {
        Log.e(TAG, "Error!", error);

}, extraHeaders);


// Later… 
client.send(new byte[] { 0xDE, 0xAD, 0xBE, 0xEF });

When I build/run the project, I get:

error: cannot find symbol class WebSocketClient

I think my question is: What is the import statement I should use?

How would I go about adding/using this code?


You ran into a bug that was fixed in Android Studio 0.4.3. I recommend you upgrade.

The auto importer was broken. Once I restarted Android Studio it showed I should put:

import com.codebutler.android_websockets.WebSocketClient;

As my import. Now I have a NullPointerException for a particular piece of code, but that's a different problem.

Need Your Help

Parsing JPEG file format: Format of entropy-coded segments (ECS)?

file format jpeg

I'm having difficulty understanding the ITU-T T.81 spec for the JPEG file format. Hopefully someone else here has tried to parse JPEG files and/or knows about the details of this file format.

How can a search engine derive structured data from an html page?

html search seo search-engine semantic-web

How does the system determine what html element contains data about which variable?