Android AsyncHttpClient, unable to find symbol class Header

Alex Stone picture Alex Stone · Apr 16, 2015 · Viewed 13.9k times · Source

I'm trying to create asynchronous rest call in Android using a library com.loopj.android.http.AsyncHttpClient however, i'm unable to implement AsyncHttpResponseHandler's overridden methods because Android Studio cannot find an appropriate import for Header class

How can I resolve the issue with the Header class not recognized by the Android Studio IDE?

 public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                // called when response HTTP status is "200 OK"
            }

I see that if I mouse over and click on the Header, I get the following message, but I don't know how to select one of the multiple choices in this menu (moving the mouse dismisses it)

enter image description here

Answer

Sharjeel Ahmed picture Sharjeel Ahmed · Sep 19, 2015

The answer by Alex is no longer valid as org.Apache.http is deprecated from API level 22.

Please replace all references of org.apache.http to cz.msebera.android.httpclient and use version 1.4.9 of loopj which includes the library.

For those who use gradle change your dependencies in build.gradle

dependencies {
  compile 'com.loopj.android:android-async-http:1.4.9'
}

Rebuild and then import cz.msebera.android.httpclient to use Header.