gradle/gradle · error · IllegalDependencyNotation

A direct library binary dependency must have all of project,

Error message

A direct library binary dependency must have all of project, library name and variant specified.

What it means

DefaultLibraryBinaryDependencySpec is the spec for depending on one exact binary variant of a library. Its constructor demands all three coordinates — projectPath, libraryName, variant — and throws IllegalDependencyNotation if any is null. The only production factory is of(LibraryBinaryIdentifier), so a null coordinate almost always means the identifier was incomplete (no project path or no variant).

Source

Thrown at platforms/native/plugins-model-native/src/main/java/org/gradle/platform/base/internal/DefaultLibraryBinaryDependencySpec.java:35

import com.google.common.base.Joiner;
import org.gradle.api.IllegalDependencyNotation;
import org.gradle.api.artifacts.component.LibraryBinaryIdentifier;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

@SuppressWarnings("deprecation")
public class DefaultLibraryBinaryDependencySpec implements org.gradle.platform.base.LibraryBinaryDependencySpec {

    private final String projectPath;
    private final String libraryName;
    private final String variant;

    public DefaultLibraryBinaryDependencySpec(String projectPath, String libraryName, String variant) {
        if (libraryName == null || projectPath == null || variant == null) {
            throw new IllegalDependencyNotation("A direct library binary dependency must have all of project, library name and variant specified.");
        }
        this.libraryName = libraryName;
        this.projectPath = projectPath;
        this.variant = variant;
    }

    @Override
    public String getProjectPath() {
        return projectPath;
    }

    @Override
    public String getLibraryName() {
        return libraryName;
    }

    @Override
    public String getVariant() {

View on GitHub (pinned to 534f27719b)

Solutions

  1. Populate all three fields on the source LibraryBinaryIdentifier before converting it (projectPath, libraryName, variant).
  2. If the variant genuinely has no flavor/buildType dimension, still pass a non-null variant name (e.g. the default variant the binary reports) rather than null.
  3. If you only mean 'this project's library' (not an exact variant), use DefaultProjectDependencySpec (dependencies { project(path).library(name) }) instead.

Example fix

// before
new DefaultLibraryBinaryDependencySpec(null, 'common', null)   // IllegalDependencyNotation
// after: derive a complete spec from a fully-populated identifier
def id = binary.getId()   // LibraryBinaryIdentifier with projectPath, libraryName, variant
DefaultLibraryBinaryDependencySpec.of(id)
Defensive patterns

Strategy: validation

Validate before calling

// Validate the identifier is complete before building the spec:
def toSpec = { LibraryBinaryIdentifier id ->
    if (id.projectPath == null || id.libraryName == null || id.variant == null) {
        throw new GradleException("Incomplete binary identifier: project=${id.projectPath} lib=${id.libraryName} variant=${id.variant}")
    }
    DefaultLibraryBinaryDependencySpec.of(id)
}

Prevention

When it happens

Trigger: Constructing the spec directly with a missing argument, or of(LibraryBinaryIdentifier) where the identifier carries a null projectPath or variant (e.g. a binary id built without a variant dimension). Thrown at spec-build time, i.e. when DependencySpecContainer.getDependencies() materializes specs.

Common situations: Plugin code building binary-level dependency specs from partial identifiers; wiring IDE/tooling features that record 'this binary depends on that exact binary' when the source identifier lacks a project or variant.

Related errors


AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22). Data as JSON: /api/errors/9a4262a700aa1055. Report an issue: GitHub.