java
build_error
ai_generated
true
Conflict found for dependency 'com.google.guava:guava' between versions 30.1.1-jre and 31.0.1-jre. Resolve using dependency constraints or force a version.
ID: java/gradle-dependency-version-conflict
80%Fix Rate
85%Confidence
0Evidence
2024-07-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 8+ | active | — | — | — |
Root Cause
Different modules in the project require different versions of the same dependency, causing a conflict.
generic中文
项目中不同模块需要相同依赖的不同版本,导致冲突。
Workarounds
-
95% success Force a specific version using Gradle's resolution strategy
configurations.all { resolutionStrategy.force 'com.google.guava:guava:31.0.1-jre' } -
90% success Add a dependency constraint in build.gradle
dependencies { constraints { implementation('com.google.guava:guava:31.0.1-jre') } }
Dead Ends
Common approaches that don't work:
-
Removing one of the conflicting dependencies without checking transitive dependencies
85% fail
The transitive dependency may still pull in the conflicting version.
-
Using compileOnly scope on one dependency
80% fail
compileOnly does not resolve the conflict at runtime; it only affects compilation.