Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Gradle Build Error

Tags:

android

I am adding dependencies in 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 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 ?

like image 799
nmkkannan Avatar asked Apr 08 '15 10:04

nmkkannan


2 Answers

You can try by adding this in your build.gradle (Module: app). It solved my issue:

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

My final build gradle looks like:

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 have pasted this 3 jars in my libs folder. You can download and do so.

like image 79
Mohammad Arman Avatar answered Nov 14 '22 21:11

Mohammad Arman


I solved this issue by replacing following line

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

with this

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

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

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

like image 26
Sohail Avatar answered Nov 14 '22 22:11

Sohail