13

I am using httpmime and httpcore in my project and I am getting this warning

Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for debug as it may be conflicting with the internal version provided by Android.

Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for debug as it may be conflicting with the internal version provided by Android.

my dependencies look like this

dependencies { compile files('libs/gson-2.2.2.jar') compile files('libs/classes.jar') compile files('libs/gcm.jar') compile files('libs/splunk-mint-4.2.jar') compile 'com.android.support:appcompat-v7:22.2.0' compile 'org.apache.httpcomponents:httpcore:4.4.1' compile 'org.apache.httpcomponents:httpmime:4.4.1'} 

As suggested in other places I added this to my build.gradle file

packagingOptions { exclude 'META-INF/DEPENDENCIES.txt' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/notice.txt' exclude 'META-INF/license.txt' exclude 'META-INF/dependencies.txt' exclude 'META-INF/LGPL2.1'} 

Any idea how to solve this issue?

5 Answers 5

12

Firstly remove the lines compile 'org.apache.httpcomponents:httpcore:4.4.1' compile 'org.apache.httpcomponents:httpmime:4.4.1'

then at their place add the lines in build.gradle given by:

compile ('org.apache.httpcomponents:httpmime:4.3'){ exclude group: 'org.apache.httpcomponents', module: 'httpclient' } compile 'org.apache.httpcomponents:httpcore:4.4.1' compile 'commons-io:commons-io:1.3.2' 

You can try this if your compileSdkVersion is 19(IN MY CASE) more preferably. Hope this will resolve the issue...

Sign up to request clarification or add additional context in comments.

Comments

9

Use repacked version of the apache http client suitable for android

dependencies { compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1' } 

https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html

1 Comment

How can I import it on MainActivity? I have to use NameValuePair from import org.apache.http
8

Solution 1

I know this is so late but i'm posting here because accepted answer was not working for me

previously i used

dependencies { compile 'org.apache.httpcomponents:httpclient:4.5' compile 'org.apache.httpcomponents:httpmime:4.3.3' compile 'org.apache.httpcomponents:httpcore:4.3.2' compile files('libs/httpclient-4.2.1.jar') compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1' } 

then i got the warning like question after that i commented some lines like bellow

dependencies { compile 'org.apache.httpcomponents:httpclient:4.5' compile 'org.apache.httpcomponents:httpmime:4.3.3' //compile 'org.apache.httpcomponents:httpcore:4.3.2' //compile files('libs/httpclient-4.2.1.jar') compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1' } 

now everything working fine

Edit

Solution 2

I got the best process than previous

add httpcore-4.3-beta1.jar and httpmime-4.3.jar in lib's folder and finally add

useLibrary 'org.apache.http.legacy' in your graddle file (Inside of android) as like bellow

android { compileSdkVersion 24 buildToolsVersion "24.0.3" //For http useLibrary 'org.apache.http.legacy' defaultConfig { applicationId "com.app.videorotation" minSdkVersion 15 targetSdkVersion 24 versionCode 1 versionName "1.0" } ...... } 

2 Comments

Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5 is ignored for debug as it may be conflicting with the internal version provided by Android. Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5 is ignored for release as it may be conflicting with the internal version provided by Android..........................still giving these warnings.
@King While you doing are commented previous http related dependencies?
0

Solution: add useLibrary 'org.apache.http.legacy' configurations { all*.exclude module: 'httpclient' }

I think some people may need this,

Comments

0

This worked for me.

If you have kept the below one :-,

compile 'org.apache.httpcomponents:httpcore:4.4.4' compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1' 

change it to this,

compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1' 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.