here is a snippet of my build.gradle:
compile 'com.google.api-client:google-api-client:1.19.0' compile 'com.google.apis:google-api-services-oauth2:v2-rev77-1.19.0' compile 'com.google.apis:google-api-services-plus:v1-rev155-1.19.0' compile 'com.google.appengine.tools:appengine-gcs-client:0.4.1' compile 'com.google.appengine.tools:appengine-mapreduce:0.8'
which imports multiple version of guava as you can see with dependencyInsight:
com.google.guava:guava:15.0 (conflict resolution) com.google.guava:guava:14.0.1 -> 15.0 +--- com.googlecode.objectify:objectify:4.1.3 | \--- default \--- net.eusashead.spring:spring-cache-gae:1.0.0.RELEASE \--- default com.google.guava:guava:[15.0,15.99] -> 15.0 +--- com.google.appengine.tools:appengine-gcs-client:0.4.1 | +--- default | +--- com.google.appengine.tools:appengine-mapreduce:0.8 | | \--- default | \--- com.google.appengine.tools:appengine-pipeline:0.2.10 | \--- com.google.appengine.tools:appengine-mapreduce:0.8 (*) +--- com.google.appengine.tools:appengine-mapreduce:0.8 (*) \--- com.google.appengine.tools:appengine-pipeline:0.2.10 (*) com.google.guava:guava-jdk5:13.0 \--- com.google.api-client:google-api-client:1.19.0 +--- default +--- com.google.apis:google-api-services-oauth2:v2-rev77-1.19.0 | \--- default +--- com.google.apis:google-api-services-plus:v1-rev155-1.19.0 | \--- default +--- com.google.appengine.tools:appengine-gcs-client:0.4.1 | +--- default | +--- com.google.appengine.tools:appengine-mapreduce:0.8 | | \--- default | \--- com.google.appengine.tools:appengine-pipeline:0.2.10 | \--- com.google.appengine.tools:appengine-mapreduce:0.8 (*) +--- com.google.api-client:google-api-client-appengine:1.17.0-rc | \--- com.google.appengine.tools:appengine-gcs-client:0.4.1 (*) +--- com.google.apis:google-api-services-storage:v1-rev1-1.18.0-rc | \--- com.google.appengine.tools:appengine-gcs-client:0.4.1 (*) +--- com.google.apis:google-api-services-bigquery:v2-rev154-1.19.0 | \--- com.google.appengine.tools:appengine-mapreduce:0.8 (*) \--- com.google.api-client:google-api-client-servlet:1.17.0-rc \--- com.google.api-client:google-api-client-appengine:1.17.0-rc (*) (*) - dependencies omitted (listed previously)
I have tried removing the dependency to : by doing:
compile ('com.google.api-client:google-api-client:1.19.0'){ exclude group: 'com.google.guava', module: 'guava-jdk5' } compile ('com.google.api-client:google-api-client:1.19.0'){ exclude group: 'com.google.guava', }
but the dependencyInsight remains the same. I also tried
compile ('com.google.guava:guava:15.0'){force = true}
but again dependency insight remains the same. How do I get rid of com.google.guava:guava-jdk5:13.0 ?
Details: I've tried gradle 1.2 and 2.1 on a windows 8.1 box
The reason for me to try this is to get rid of this exception:
java.lang.NoSuchMethodError: com.google.common.base.Stopwatch.createStarted()Lcom/google/common/base/Stopwatch;
When you specify a dependency in your build script, you can provide an exclude rule at the same time telling Gradle not to pull in the specified transitive dependency. For example, say we have a Gradle project that depends on Google's Guava library, or more specifically com. google. guava:guava:30.1.
To override the version of a transitive dependency in Gradle, exclude it from the declared dependency that pulls it in, and then explicitly declare the version that you prefer to use in your build.
Gradle automatically resolves those additional modules, so called transitive dependencies. If needed, you can customize the behavior the handling of transitive dependencies to your project's requirements. Projects with tens or hundreds of declared dependencies can easily suffer from dependency hell.
It seems a dependency will not be excluded if there is another dependency somewhere that points to that same dependency without any of the excludes.
You can exclude a dependency through configuration
however:
configurations { all*.exclude group: 'com.google.guava', module:'guava-jdk5' }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With