I use the following two dependencies:
compile 'com.google.guava:guava:14.0.1' compile 'com.google.guava:guava-gwt:14.0.1'
Both must be the same version to work correctly. Since my other dependencies use a higher version, Gradle uses different versions for each dependency.
I found this by running gradle dependencies
:
compile - Compile classpath for source set 'main'. +--- com.google.guava:guava:14.0.1 -> 17.0 +--- com.google.guava:guava-gwt:14.0.1 | +--- com.google.code.findbugs:jsr305:1.3.9 | \--- com.google.guava:guava:14.0.1 -> 17.0
How can I force Gradle to set the same version for these two dependencies?
Simply open the gradle tab (can be located on the right) and right-click on the parent in the list (should be called "Android"), then select "Refresh dependencies". This should resolve your issue.
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.
A variant of a component can have dependencies on other modules to work properly, so-called transitive dependencies. Releases of a module hosted on a repository can provide metadata to declare those transitive dependencies. By default, Gradle resolves transitive dependencies automatically.
Hello , can i create multiple build. gradle for one project? Yes. You can have multiple build files in one project.
Add this section to dependencies.gradle file
configurations.all { resolutionStrategy { force 'com.google.guava:guava:14.0.1' force 'com.google.guava:guava-gwt:14.0.1' } }
configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.google.guava') { details.useVersion "14.0.1" } } } dependencies { compile 'com.google.guava:guava' compile 'com.google.guava:guava-gwt' }
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