user5287166
user5287166

Reputation: 223

Import header gives error on Android stuidio

I am getting cannot resolve symbol 'Header' when I am trying to use AsyncHttpClient.

AsyncHttpClient client = new AsyncHttpClient();
client.post(uploadWebsite, requestParams, new JsonHttpResponseHandler()
{
  @Override
  public void onSuccess(int statusCode, Header[] headers, JSONObject response)
  {

  }
}

@Override
public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse)
{
  super.onFailure(statusCode, headers, throwable, errorResponse);
  Toast.makeText(OZI_Wishlist.this, "Unable to connect to server. Check your network !!", Toast.LENGTH_SHORT).show();
  }
});

Snapshot of the import issue. enter image description here

Can somebody tell me what is wrong?

Thanks!

Upvotes: 1

Views: 2226

Answers (2)

GorvGoyl
GorvGoyl

Reputation: 49460

Use cz.msebera.android library

Add it to build.gradle file:

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

Rebuild/sync and then import to java class:

import cz.msebera.android.httpclient.*;

Upvotes: 0

AndiGeeky
AndiGeeky

Reputation: 11464

Please add below dependency in your gradle file.

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

Because Header[] is part of HttpCore not AsyncHttpClient library..!!

Upvotes: 4

Related Questions