I cannot build a simple metric from a java application using the Stackdriver Monitoring client when I have a dependency to the Google Dataflow client.
I get the exception:
Exception in thread "main" java.lang.NoSuchMethodError: io.grpc.okhttp.OkHttpChannelProvider.isAndroid()Z
at io.grpc.okhttp.OkHttpChannelProvider.priority(OkHttpChannelProvider.java:51)
at io.grpc.ManagedChannelProvider$1.getPriority(ManagedChannelProvider.java:49)
at io.grpc.ManagedChannelProvider$1.getPriority(ManagedChannelProvider.java:41)
at io.grpc.ServiceProviders$1.compare(ServiceProviders.java:78)
at java.util.Collections$ReverseComparator2.compare(Collections.java:5178)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
at java.util.TimSort.sort(TimSort.java:220)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1462)
at java.util.Collections.sort(Collections.java:175)
at io.grpc.ServiceProviders.loadAll(ServiceProviders.java:75)
at io.grpc.ServiceProviders.load(ServiceProviders.java:42)
at io.grpc.ManagedChannelProvider.<clinit>(ManagedChannelProvider.java:37)
at io.grpc.ManagedChannelBuilder.forAddress(ManagedChannelBuilder.java:36)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:185)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:157)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:149)
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:151)
at com.google.cloud.monitoring.v3.stub.GrpcMetricServiceStub.create(GrpcMetricServiceStub.java:173)
at com.google.cloud.monitoring.v3.stub.MetricServiceStubSettings.createStub(MetricServiceStubSettings.java:184)
at com.google.cloud.monitoring.v3.MetricServiceClient.<init>(MetricServiceClient.java:158)
at com.google.cloud.monitoring.v3.MetricServiceClient.create(MetricServiceClient.java:139)
at com.google.cloud.monitoring.v3.MetricServiceClient.create(MetricServiceClient.java:130)
at SimpleMetric.main(SimpleMetric.java:7)
on the create method:
import com.google.cloud.monitoring.v3.MetricServiceClient;
import java.io.IOException;
public class SimpleMetric {
public static void main(String... args) throws IOException {
MetricServiceClient metricServiceClient = MetricServiceClient.create();
}
}
only when I add:
compile 'com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:2.5.0'
as in my gradle file as a dependency.
plugins {
id 'java'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.cloud:google-cloud-monitoring:1.48.0'
// exception with the dependency below
compile 'com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:2.5.0'
}
I reported the issue to Google. In the meantime, is there a workaround?