Which httpmime version can I use with Android's HttpClient?
Asked Answered
C

2

3

I need to upload files using Android's HttpClient. Unfortunately, Android doesn't include MultipartEntity, so I must using Apache's httpmime library.

I don't want to incur possible conflicts between the Android's HttpClient and the official HttpClient. Also, I don't want to bring in more outside libraries than I have to because I need to keep my method count low.

What version of httpmime will work with Android's HttpClient? All of the questions I've seen recommending httpmime also recommend using Apache's official HttpClient or HttpCore.

(I know I should use Retrofit, but I must use Android's HttpClient for compatibility with other libraries.)

Congruence answered 15/7, 2014 at 14:49 Comment(0)
C
6

httpmime-4.2.6.jar worked fine all by itself. I needed no other dependencies besides that jar.

If you're using a dependency-managing build system like Maven or gradle, you'll notice that httpmime-4.2.6 depends on httpcore-4.2.5. Android's HttpClient seems compatible with httpcore-4.2.5, so I just excluded that dependency. My actual dependency declaration is below:

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpmime</artifactId>
    <version>4.2.6</version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
        </exclusion>
    </exclusions>
</dependency>
Congruence answered 16/7, 2014 at 14:22 Comment(0)
C
7
dependencies {
    compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5'
    compile 'org.apache.httpcomponents:httpmime:4.3.5'
}
Candor answered 19/11, 2014 at 6:45 Comment(1)
though compile 'org.apache.httpcomponents:httpclient-android:4.3.5'might look nicer.Dermatome
C
6

httpmime-4.2.6.jar worked fine all by itself. I needed no other dependencies besides that jar.

If you're using a dependency-managing build system like Maven or gradle, you'll notice that httpmime-4.2.6 depends on httpcore-4.2.5. Android's HttpClient seems compatible with httpcore-4.2.5, so I just excluded that dependency. My actual dependency declaration is below:

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpmime</artifactId>
    <version>4.2.6</version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
        </exclusion>
    </exclusions>
</dependency>
Congruence answered 16/7, 2014 at 14:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.