gradle/gradle · error · LibraryResolveException
No %s library binary available for library '%s' with [flavor
Error message
No %s library binary available for library '%s' with [flavor: '%s', platform: '%s', buildType: '%s']
What it means
The required library exists, but LibraryResolution filters its candidate binaries by the requester's flavor, targetPlatform and buildType, and by the class implied by the linkage. If nothing survives filtering, LibraryResolveException is thrown listing the exact dimensions that failed to match, so the message tells you which axis (flavor/platform/buildType/linkage) is misaligned.
Source
Thrown at platforms/native/plugins-model-native/src/main/java/org/gradle/nativeplatform/internal/resolve/DefaultLibraryResolver.java:112
}
private org.gradle.nativeplatform.NativeLibraryBinary resolve(Set<? extends org.gradle.nativeplatform.NativeLibraryBinary> candidates) {
for (org.gradle.nativeplatform.NativeLibraryBinary candidate : candidates) {
if (flavor != null && !flavor.getName().equals(candidate.getFlavor().getName())) {
continue;
}
if (platform != null && !platform.getName().equals(candidate.getTargetPlatform().getName())) {
continue;
}
if (buildType != null && !buildType.getName().equals(candidate.getBuildType().getName())) {
continue;
}
return candidate;
}
String typeName = GUtil.elvis(requirement.getLinkage(), "shared");
throw new LibraryResolveException(String.format("No %s library binary available for library '%s' with [flavor: '%s', platform: '%s', buildType: '%s']",
typeName, requirement.getLibraryName(), flavor.getName(), platform.getName(), buildType.getName()));
}
}
}
View on GitHub (pinned to 534f27719b)
Solutions
- Mirror the variant dimensions: give the required library the same targetPlatforms/flavors/buildTypes as the consuming component so a matching binary gets built.
- If the library only produces one linkage, request exactly that one (linkage 'static' or 'shared').
- Compare the dimensions in the message against the library's declared dimensions using the 'model' report.
- For prebuilt libraries, declare binaries (files) for every platform the consumers request, or restrict the consumer's target platforms.
Example fix
// before
model {
components {
app(NativeExecutableSpec) { targetPlatforms 'linux', 'windows' }
util(NativeLibrarySpec) { } // default platform only -> no 'windows' binary
}
}
// after
model {
components {
app(NativeExecutableSpec) { targetPlatforms 'linux', 'windows' }
util(NativeLibrarySpec) { targetPlatforms 'linux', 'windows' }
}
} Defensive patterns
Strategy: validation
Validate before calling
// Keep variant dimensions aligned: define platforms/flavors once and reuse everywhere // build.gradle (shared via apply from: or a convention plugin): ext.nativePlatforms = ['linux', 'windows'] // then in every component: // targetPlatforms project.ext.nativePlatforms as String[] // A library missing any consumer dimension is exactly what produces // "No <linkage> library binary available ... [flavor, platform, buildType]".
Prevention
- Define targetPlatforms/flavors/buildTypes in one shared place and apply them to components AND their libraries
- When adding cross-compilation to a consumer, add the same target to every library it depends on in the same change
- Read the dimensions in the message: they tell you exactly which axis has no matching binary
When it happens
Trigger: A consumer builds for platform X (targetPlatforms 'windows') while the library only produces binaries for its default platform; custom flavors or buildTypes declared on one component but not the library; requiring 'shared' when the library (or prebuilt) only offers a static binary, or vice versa.
Common situations: Adding cross-compilation targets to an executable but not to its library dependencies; introducing per-project custom flavors/buildTypes; prebuilt libraries that declare artifacts for only one platform or linkage.
Related errors
- Unsupported operating system family of name '{name}'
- Invalid %s: %s
- Unable to build native dependent binaries resolution cache
- Could not locate library '%s' required by %s.
- Unable to get system memory
AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22).
Data as JSON: /api/errors/d6cf5b1e3290a206.
Report an issue: GitHub.