java build_error ai_generated true

发现依赖 'com.google.guava:guava' 版本冲突:30.1.1-jre 与 31.0.1-jre。请使用依赖约束或强制指定版本。

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

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
0证据数
2024-07-22首次发现

版本兼容性

版本状态引入弃用备注
8+ active

根因分析

项目中不同模块需要相同依赖的不同版本,导致冲突。

English

Different modules in the project require different versions of the same dependency, causing a conflict.

generic

解决方案

  1. 95% 成功率 Force a specific version using Gradle's resolution strategy
    configurations.all { resolutionStrategy.force 'com.google.guava:guava:31.0.1-jre' }
  2. 90% 成功率 Add a dependency constraint in build.gradle
    dependencies { constraints { implementation('com.google.guava:guava:31.0.1-jre') } }

无效尝试

常见但无效的做法:

  1. Removing one of the conflicting dependencies without checking transitive dependencies 85% 失败

    The transitive dependency may still pull in the conflicting version.

  2. Using compileOnly scope on one dependency 80% 失败

    compileOnly does not resolve the conflict at runtime; it only affects compilation.