0

I am new to AsyncHttpClient and I am not able to implement AsyncHttpResponseHandler. Whenever I implement it, I have to override 2 methods onSuccess and onFailure.

Both these methods are taking as parameter the following:-

client.get(cityURL, new AsyncHttpResponseHandler() {
    @Override
    public void onSuccess(int i, cz.msebera.android.httpclient.Header[] headers, byte[] bytes) {

    }

    @Override
    public void onFailure(int i, cz.msebera.android.httpclient.Header[] headers, byte[] bytes, Throwable throwable) {

    }

I am getting error in 'cz' saying Cannot recognize symbol 'cz'. I have tried adding the following dependencies :-

  1. compile 'com.loopj.android:android-async-http:1.4.9'
  2. compile 'org.apache.httpcomponents:httpcore:4.4.1'

But sync is failing if I use them. Any help on this would be much appreciated.

Kevin Kopf
  • 13,327
  • 14
  • 49
  • 66
  • When I try removing "cz.msebera.android.httpclient." from the argument, Header gives error as cannot resolve symbol "Header" with no option to import header. I tried with "import org.apache.http.Header;" but still this issue persists. Please help. – Kaushik Saha Sep 14 '16 at 11:24
  • try and just use Header[] headers instead of the complete name. Also, if you just want to make an Async call then it's better to just use retrofit. – Kaveesh Kanwal Sep 14 '16 at 12:13
  • @KaveeshKanwal...I tried the solution you are offerring...then error says "Cannot resolve symbol Header" – Kaushik Saha Sep 14 '16 at 12:36

1 Answers1

1

Add this dependency in your build.gradle

dependencies {
  compile "cz.msebera.android:httpclient:4.4.1.2"
}
Viral Patel
  • 32,418
  • 18
  • 82
  • 110
  • @AndroidMechanic...I have added the dependency, in this case gradle sync is failing...with the error : Failed to resolve cz.msebera.android:httpclient:4.4.1.2 – Kaushik Saha Sep 14 '16 at 12:42