30

I'm trying to add the following dependency but it is ignore. I can't understand how to resolve it please help me Thank you.

Dependency

 compile 'com.google.apis:google-api-services-drive:v2-rev170-1.20.0'

Waring for ignoring dependency
Warning:Dependency org.apache.httpcomponents:httpclient:4.0.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.0.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

Bojan Kseneman
  • 15,488
  • 2
  • 54
  • 59
Asim Habib
  • 381
  • 1
  • 4
  • 12

3 Answers3

52

You can exclude dependencies in the build.gradle file of your module.

compile('com.google.apis:google-api-services-drive:v2-rev170-1.20.0') {
    exclude module: 'httpclient' //by artifact name
    exclude group: 'org.apache.httpcomponents' //by group
    exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group
}
Aegis
  • 5,761
  • 2
  • 33
  • 42
  • 11
    Are there any risks to excluding these dependencies? Google Drive will now be using a newer version of httpclient from apache. – Simon Aug 02 '15 at 18:57
28

Exclude module httpclient from all configurations. Add this code in the build.gradle file:

configurations {
    compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}
anshuraj
  • 332
  • 1
  • 5
  • 16
teh.fonsi
  • 3,040
  • 2
  • 27
  • 22
  • 1
    Thanks. Only this working for my case. `compile('com.google.apis:google-api-services-drive:v2-rev170-1.20.0') { exclude module: 'httpclient' //by artifact name exclude group: 'org.apache.httpcomponents' //by group exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group }` is not working. – sky91 Jun 14 '16 at 18:53
2

Use the following code to exclude the conflicting modules from the google APIs library.

 compile 'com.google.apis:google-api-services-drive:v2-rev170-1.20.0' {
    exclude module: 'httpcore'
    exclude module: 'httpclient'
}
Bojan Kseneman
  • 15,488
  • 2
  • 54
  • 59
  • 3
    Could you please explain this answer and why it should work (as opposed to the original code)? – Dev-iL May 26 '15 at 17:27