gradle/gradle · error · GradleException
Expected all requested coordinates to resolve to the same co
Error message
Expected all requested coordinates to resolve to the same component coordinates.
What it means
When publishing resolved dependency coordinates, ResolutionBackedPublicationDependencyResolver walks first-level edges of the published variant and asserts that one requested module identifier always resolves to the same component coordinates across edges; a mismatch throws GradleException. It is an internal consistency invariant: the same module resolving to different components within a single publish is unsupported.
Source
Thrown at platforms/software/publish/src/main/java/org/gradle/api/publish/internal/mapping/ResolutionBackedPublicationDependencyResolver.java:118
Set<ModuleDependencyKey> incompatibleModuleDeps = new HashSet<>();
Set<ProjectDependencyKey> incompatibleProjectDeps = new HashSet<>();
Map<ModuleIdentifier, ModuleVersionIdentifier> resolvedModuleComponents = new HashMap<>();
Map<Path, ModuleVersionIdentifier> resolvedProjectComponents = new HashMap<>();
Map<ModuleDependencyKey, ModuleVersionIdentifier> resolvedModuleVariants = new HashMap<>();
Map<ProjectDependencyKey, ModuleVersionIdentifier> resolvedProjectVariants = new HashMap<>();
visitFirstLevelEdges(rootComponent, rootVariant, edge -> {
ComponentSelector requested = edge.getRequested();
CoordinatePair coordinates = getResolvedCoordinates(edge.getResolvedVariant(), projectDependencyResolver, moduleIdentifierFactory);
if (requested instanceof ModuleComponentSelector) {
ModuleComponentSelector requestedModule = (ModuleComponentSelector) requested;
ModuleVersionIdentifier existingComponent = resolvedModuleComponents.put(requestedModule.getModuleIdentifier(), coordinates.componentCoordinates);
if (existingComponent != null && !existingComponent.equals(coordinates.componentCoordinates)) {
throw new GradleException("Expected all requested coordinates to resolve to the same component coordinates.");
}
ModuleDependencyKey key = new ModuleDependencyKey(requestedModule.getModuleIdentifier(), ModuleDependencyDetails.from(requested));
if (incompatibleModuleDeps.contains(key)) {
return;
}
ModuleVersionIdentifier existingVariant = resolvedModuleVariants.put(key, coordinates.variantCoordinates);
if (existingVariant != null && !existingVariant.equals(coordinates.variantCoordinates)) {
resolvedModuleVariants.remove(key);
incompatibleModuleDeps.add(key);
}
} else if (requested instanceof ProjectComponentSelector) {
ProjectComponentSelectorInternal requestedProject = (ProjectComponentSelectorInternal) requested;
ModuleVersionIdentifier existingComponent = resolvedProjectComponents.put(requestedProject.getIdentityPath(), coordinates.componentCoordinates);
if (existingComponent != null && !existingComponent.equals(coordinates.componentCoordinates)) {
throw new GradleException("Expected all requested projects to resolve to the same component coordinates.");View on GitHub (pinned to 534f27719b)
Solutions
- Inspect the resolved graph of the resolution configuration (gradle dependencies --configuration <config> and dependencyInsight --dependency <module-from-the-stack-trace>)
- Make substitution/replacement rules apply consistently to every edge (resolutionStrategy.eachDependency / dependencySubstitution on all relevant configurations)
- Verify every repository serving that GAV returns identical content; exclude the repository that serves the divergent component
- If the inconsistency is unavoidable, fall back to publishing declared coordinates by disabling publishResolvedCoordinates
Defensive patterns
Strategy: fallback
Validate before calling
configurations.named('mappedRuntimeElements') {
it.incoming.afterResolve {
it.resolutionResult.allComponents.each { c ->
logger.lifecycle "resolved: ${c.id}"
}
}
} Prevention
- Check the resolution graph of the published configuration before enabling publishResolvedCoordinates
- Apply dependency substitution rules uniformly to all configurations involved in the publish
- Ensure all repositories serve identical content for a given GAV
- Keep publishResolvedCoordinates = false when the graph cannot be made consistent
When it happens
Trigger: The same module identifier requested with different selectors/attributes on different edges resolving to different component coordinates - typically caused by dependency substitution rules applied inconsistently, capability conflicts resolved differently per edge, or multiple repositories serving different content for the same GAV.
Common situations: Composite builds substituting a module on one edge while another edge resolves the external artifact; repository content filters or exclusive-repository rules splitting resolution; custom resolutionStrategy rules that fire only for some configurations.
Related errors
- Expected all requested projects to resolve to the same compo
- Unsupported dependency type: %s
- Could not map coordinates for ${displayName}.
- The version of 'scala-library' was changed while using the d
- Cannot infer Scala class path because no Scala library Jar w
AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22).
Data as JSON: /api/errors/def88c8bc6320100.
Report an issue: GitHub.