2

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]

Stephane Landelle
  • 6,990
  • 2
  • 23
  • 29
ToniApps
  • 88
  • 1
  • 11

3 Answers3

5

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.

E-Riddie
  • 14,660
  • 7
  • 52
  • 74
denis_lor
  • 6,212
  • 4
  • 31
  • 55
2

The Apache http package is deprecated as of Android 6.0

Instead you should use this (re)package.

if you are using gradle:

  dependencies {
      compile "cz.msebera.android:httpclient:4.4.1.1"
  }
doubleorseven
  • 354
  • 4
  • 8
0

Add to your lower-level build.gradle and import Header[]

dependencies {
     compile 'org.apache.httpcomponents:httpcore:4.4.4'
}

Followed by newest version available

OR

dependencies {
    compile 'httpcomponents-httpcore:httpcore:4.0-alpha6'
}

Followed by Gradle please

Damian Kozlak
  • 7,065
  • 10
  • 45
  • 51