当我对Google Dataflow客户端有依赖性时,无法使用Stackdriver Monitoring客户端从Java应用程序构建简单的指标。
我得到了例外:
fg
关于创建方法:
background-size: contain;
仅当我添加时:
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)
作为我的gradle文件中的依赖项。
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();
}
}
我向Google报告了the issue。同时,是否有解决方法?
答案 0 :(得分:0)
isAndroid
在io.grpc.ManagedChannelProvider taken out of grpc-core in version 1.11中定义。该错误表示您以某种方式使用1.11之前的grpc-okhttp和1.11或更高版本的grpc-core。
google-cloud-monitoring 1.48.0间接取决于grpc-core 1.13:
com.google.cloud:google-cloud-monitoring:jar:1.48.0:compile
+- com.google.cloud:google-cloud-core:jar:1.48.0:compile
+- com.google.cloud:google-cloud-core-grpc:jar:1.48.0:compile
| +- io.grpc:grpc-protobuf:jar:1.13.1:compile
| | \- io.grpc:grpc-protobuf-lite:jar:1.13.1:compile
| +- io.grpc:grpc-context:jar:1.13.1:compile
+- com.google.api.grpc:proto-google-cloud-monitoring-v3:jar:1.30.0:compile
+- io.grpc:grpc-netty-shaded:jar:1.13.1:compile
| \- io.grpc:grpc-core:jar:1.13.1:compile (version selected from constraint [1.13.1,1.13.1])
| +- com.google.errorprone:error_prone_annotations:jar:2.1.2:compile
| +- io.opencensus:opencensus-api:jar:0.12.3:compile
| \- io.opencensus:opencensus-contrib-grpc-metrics:jar:0.12.3:compile
+- io.grpc:grpc-stub:jar:1.13.1:compile
\- io.grpc:grpc-auth:jar:1.13.1:compile
google-cloud-dataflow-java-sdk-all 2.5.0间接取决于grpc-core 1.2和grpc-okhttp 1.2:
com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.5.0:compile
+- org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.5.0:compile
| +- io.grpc:grpc-core:jar:1.2.0:compile
| | +- com.google.errorprone:error_prone_annotations:jar:2.0.11:compile
| | +- io.grpc:grpc-context:jar:1.2.0:compile
| | \- com.google.instrumentation:instrumentation-api:jar:0.3.0:compile
| +- com.google.api:gax-grpc:jar:0.20.0:compile
| | +- io.grpc:grpc-protobuf:jar:1.2.0:compile
| | +- com.google.api:api-common:jar:1.1.0:compile
| | +- com.google.auto.value:auto-value:jar:1.2:compile
| | +- com.google.api:gax:jar:1.3.1:compile
| | \- org.threeten:threetenbp:jar:1.3.3:compile
| +- io.grpc:grpc-auth:jar:1.2.0:compile
| +- io.grpc:grpc-netty:jar:1.2.0:compile
| +- io.grpc:grpc-stub:jar:1.2.0:compile
| +- io.grpc:grpc-all:jar:1.2.0:compile
| | +- io.grpc:grpc-okhttp:jar:1.2.0:compile
| | | +- com.squareup.okhttp:okhttp:jar:2.5.0:compile
| | | \- com.squareup.okio:okio:jar:1.6.0:compile
因此,基本上,数据流已过时并引起冲突。不再支持dataflow SDK,因为现在是Apache Beam。考虑migrating解决此问题。