Search code examples
androidandroid-studioloopj

LoopJ Header[] error


I'm trying to use LoopJ but it gives me an error on the Header[] params like on the image below. It say that I need to import the Header package but when I do it it gives me another error on FileAsyncHttpResponseHandler.

AsyncHttpClient client = new AsyncHttpClient();
        client.get("https://example.com/file.png", new FileAsyncHttpResponseHandler(/* Context */ this) {
            @Override
            public void onFailure(int i, Header[] headers, Throwable throwable, File file) {

            }

            @Override
            public void onSuccess(int i, Header[] headers, File file) {

            }


        });

image of the error]


Solution

  • In your gradle file you should also add this dependency:

    compile 'org.apache.httpcomponents:httpcore:4.4.1'
    

    Header[] is part of HttpCore not AsyncHttpClient library.