{"record":{"id":"edf0e13c64b69570","repo":"grpc/grpc-java","slug":"no-functional-channel-service-provider-found-try","errorCode":null,"errorMessage":"No functional channel service provider found. Try adding a dependency on the grpc-okhttp, grpc-netty, or grpc-netty-shaded artifact","messagePattern":"No functional channel service provider found\\. Try adding a dependency on the grpc-okhttp, grpc-netty, or grpc-netty-shaded artifact","errorType":"exception","errorClass":"ProviderNotFoundException","httpStatus":null,"severity":"critical","filePath":"api/src/main/java/io/grpc/ManagedChannelProvider.java","lineNumber":45,"sourceCode":" * automatic discovery, the implementation must have a zero-argument constructor and include\n * a resource named {@code META-INF/services/io.grpc.ManagedChannelProvider} in their JAR. The\n * file's contents should be the implementation's class name.\n *\n * <p>Implementations <em>should not</em> throw. If they do, it may interrupt class loading. If\n * exceptions may reasonably occur for implementation-specific reasons, implementations should\n * generally handle the exception gracefully and return {@code false} from {@link #isAvailable()}.\n */\n@Internal\npublic abstract class ManagedChannelProvider {\n  /**\n   * Returns the ClassLoader-wide default channel.\n   *\n   * @throws ProviderNotFoundException if no provider is available\n   */\n  public static ManagedChannelProvider provider() {\n    ManagedChannelProvider provider = ManagedChannelRegistry.getDefaultRegistry().provider();\n    if (provider == null) {\n      throw new ProviderNotFoundException(\"No functional channel service provider found. \"\n          + \"Try adding a dependency on the grpc-okhttp, grpc-netty, or grpc-netty-shaded \"\n          + \"artifact\");\n    }\n    return provider;\n  }\n\n  /**\n   * Whether this provider is available for use, taking the current environment into consideration.\n   * If {@code false}, no other methods are safe to be called.\n   */\n  protected abstract boolean isAvailable();\n\n  /**\n   * A priority, from 0 to 10 that this provider should be used, taking the current environment into\n   * consideration. 5 should be considered the default, and then tweaked based on environment\n   * detection. A priority of 0 does not imply that the provider wouldn't work; just that it should\n   * be last in line.\n   */","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/api/src/main/java/io/grpc/ManagedChannelProvider.java#L27-L63","documentation":"grpc-java locates a transport implementation (e.g. netty or okhttp) via java.util.ServiceLoader at runtime. When no transport jar is on the classpath, ManagedChannelProvider.provider() finds no registered provider and throws ProviderNotFoundException. The API module alone cannot create channels; a concrete transport artifact must be present.","triggerScenarios":"Calling ManagedChannelBuilder.forAddress(...) / forTarget(...), or ManagedChannelProvider.provider() / ManagedChannelRegistry.newChannelBuilder(...), when the classpath contains grpc-api but no transport provider (grpc-netty, grpc-netty-shaded, or grpc-okhttp) registered via META-INF/services.","commonSituations":"Adding io.grpc:grpc-api or a thin client library as a direct dependency without a transport; dependency exclusions stripping grpc-netty; building an Android app without grpc-okhttp; shaded/relocated classpaths where the service file is missing; using a wrong artifact like grpc-core only.","solutions":["Add a transport dependency, e.g. implementation 'io.grpc:grpc-netty-shaded:1.x.y' (Android: grpc-okhttp)","Run mvn dependency:tree / gradle dependencies and confirm a grpc transport artifact is present and not excluded","If packaging a fat/shaded jar, ensure META-INF/services/io.grpc.ManagedChannelProvider files are merged (ServicesResourceTransformer in shade plugin)","Check for duplicate grpc-api versions causing provider registration mismatch via dependency management"],"exampleFix":"// before\ndependencies {\n    implementation 'io.grpc:grpc-api:1.62.2'\n}\n// after\ndependencies {\n    implementation 'io.grpc:grpc-netty-shaded:1.62.2'\n}","handlingStrategy":"validation","validationCode":"boolean hasTransport;\ntry {\n  Class.forName(\"io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider\");\n  hasTransport = true;\n} catch (ClassNotFoundException e) {\n  hasTransport = false; // also try okhttp provider class before failing\n}\nif (!hasTransport) throw new IllegalStateException(\"Add grpc-netty-shaded or grpc-okhttp to the classpath\");","typeGuard":"static boolean hasChannelProvider() {\n  return ManagedChannelRegistry.getDefaultRegistry().providers() != null\n      && !ManagedChannelRegistry.getDefaultRegistry().providers().isEmpty();\n}","tryCatchPattern":"try {\n  ManagedChannel channel = ManagedChannelBuilder.forAddress(host, port).build();\n} catch (ProviderNotFoundException e) {\n  throw new IllegalStateException(\"Missing grpc transport dependency: add grpc-netty-shaded/grpc-okhttp\", e);\n}","preventionTips":["Always depend on a concrete transport artifact (grpc-netty-shaded, grpc-netty, or grpc-okhttp), never grpc-api alone","For Android use grpc-okhttp; for servers/JVM prefer grpc-netty-shaded","Check dependency tree for exclusions removing grpc transports","When shading, merge META-INF/services files with ServicesResourceTransformer"],"tags":["grpc","classpath","dependency","serviceloader","transport"],"backgroundTag":"missing-dependency","analyzedSha":"64daddc1f3d1975670f769f3e97bde8b2ba32d25","analyzedAt":"2026-09-08T06:14:57.704Z","contentChangedAt":"2026-09-08T06:14:57.704Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}