gradle/gradle · error · UnknownServiceException

No service of type %s available.

Error message

No service of type %s available.

What it means

DefaultTransform wraps a service registry scoped to the transform; its get(Type) throws UnknownServiceException 'No service of type ... available.' when no service of the requested type is registered in the transform's isolated scope or its delegate. Artifact transforms run in isolation and only see services explicitly provided to them, so lookups of application/project services fail.

Source

Thrown at platforms/software/dependency-management/src/main/java/org/gradle/api/internal/artifacts/transform/DefaultTransform.java:482

            }
            return null;
        }

        @Nullable
        @Override
        public Object find(Type serviceType) throws ServiceLookupException {
            Object result = find(serviceType, null);
            if (result != null) {
                return result;
            }
            return delegate.find(serviceType);
        }

        @Override
        public Object get(Type serviceType) throws UnknownServiceException, ServiceLookupException {
            Object result = find(serviceType);
            if (result == null) {
                throw new UnknownServiceException(serviceType, "No service of type " + serviceType + " available.");
            }
            return result;
        }

        @Override
        public Object get(Type serviceType, Class<? extends Annotation> annotatedWith) throws UnknownServiceException, ServiceLookupException {
            Object result = find(serviceType, annotatedWith);
            if (result != null) {
                return result;
            }
            return delegate.get(serviceType, annotatedWith);
        }

        private static class InjectionPoint {
            private final Class<? extends Annotation> annotation;
            private final Type injectedType;
            private final Supplier<Object> valueToInject;

View on GitHub (pinned to 534f27719b)

Solutions

  1. Move the service-dependent work outside the transform and pass its results in through transform parameters.
  2. Use only services documented for transforms (e.g. ObjectFactory via getParameters() patterns) and express configuration through parameters.
  3. If a service genuinely belongs to the transform, register it as part of the transform's registration/parameters rather than looking it up at runtime.

Example fix

// before: transform looks up an application-scoped service
class MyTransform extends ArtifactTransform {
  void transform(File input) {
    def svc = registry.get(CustomIndexer) // UnknownServiceException in transform scope
  }
}
// after: do the work outside, pass data via parameters
abstract class MyParams implements TransformParameters {
  abstract Property<String> getIndexLocation()
}
// compute index location before registration, set it in parameters { }
Defensive patterns

Strategy: try-catch

Try / catch

try {
  def svc = registry.get(MyService)
} catch (org.gradle.internal.service.UnknownServiceException e) {
  // service not available in transform scope: pass its data via transform parameters instead
  throw e
}

Prevention

When it happens

Trigger: Code executing inside an ArtifactTransform calling a service locator get() for a type not registered in the transform scope — e.g. project-level singletons, custom application services, or services never passed into the transform registration.

Common situations: Porting code that used build services or application services into an artifact transform; custom transforms trying to reach internal APIs; worker isolation surfacing previously hidden coupling.

Related errors


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