Android Gradle Build Error

I add dependencies in the build.gradle file.

My code is:

dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.google.android.gms:play-services:6.1.11' compile 'org.apache.httpcomponents:httpmime:4.4.1' compile 'org.apache.httpcomponents:httpcore:4.4.1' compile 'org.apache.httpcomponents:httpclient:4.4.1' 

}

I got an error:

 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. In case of problem, please repackage it with jarjar to change the class packages 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. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages 

How to solve this problem. Please help me?

+5
source share
5 answers

You can try adding this to your build.gradle (Module: app). He solved my problem:

 packagingOptions{ exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' } 

My latest gradle build is as follows:

 apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "info.androidhive.camerafileupload" minSdkVersion 19 targetSdkVersion 21 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } packagingOptions{ exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' } } dependencies { compile 'com.android.support:appcompat-v7:21.0.3' compile files('libs/httpclient-4.3.6.jar') compile files('libs/httpcore-4.3.3.jar') compile files('libs/httpmime-4.3.6.jar') } 

NB: In my case, I inserted these 3 jars into my libs folder. You can download and do it.

+8
source

I solved this problem by replacing the following line

 compile "org.apache.httpcomponents:httpclient:4.4.1" 

with this

 compile "org.apache.httpcomponents:httpclient-android:4.3.5.1" 

Please visit the following URL if you want to know more about HttpClient for Android

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

+4
source

I solved the problem using this if your compileSdkVersion is 19 (IN MY CASE)

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

else if your compileSdkVersion is 23 then use

 android { useLibrary 'org.apache.http.legacy' packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' } } 
+2
source

Instead of adding exclude to each library, you can add the following configuration for all libraries:

 configurations { all*.exclude group: 'org.apache.httpcomponents',module: 'httpclient' } 
+2
source

If nothing works try this .definitely work

replace it

  dependencies { ...... ....... compile 'org.apache.httpcomponents:httpclient:4.4.1' } 

with code below

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

All Articles