我正在使用 Java 中的 Cloud Vision API 使用 IntelliJ 来检测相机图片中的标签。API 工作正常,但是当我将 android.graphics 依赖项添加到我的 maven pom.xml 以使用位图 ADT 时,它停止工作并抛出错误:“找不到功能通道服务提供程序。尝试添加对 grpc 的依赖项-okhttp 或 grpc-netty 神器”。我尝试将下面的依赖项添加到我的 pom.xml 中,但没有任何改变。有人可以告诉我这个错误是什么意思吗?
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-okhttp</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.22.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
导入 android.graphics.Bitmap;
public static void main(String... args) throws Exception {
Bitmap bmp;
String description = "";
// Instantiates a client
try (ImageAnnotatorClient vision = ImageAnnotatorClient.create()) {
// The path to the image file to annotate
String fileName = "c:/stairsPic.png";
// …Run Code Online (Sandbox Code Playgroud)