gpt4 book ai didi

android - cloud.speech.v1.StreamingRecognizeResponse - 错误 : an enum switch case label must be the unqualified name of an enumeration constant

转载 作者:行者123 更新时间:2023-12-05 00:05:25 36 4
gpt4 key购买 nike

一年前,我使用来自 github 的 Google Cloud Platform Java 示例项目在 Android Studio 中创建了一个项目。当时它工作正常,但一个月前当我打开项目时,我遇到了以下错误:

error: an enum switch case label must be the unqualified name of an enumeration constant

我检查了关于 SO 的其他解决方案,Ex ,但在 StreamingRecognizeResponse 类上,我看到代码是按照解决方案建议编写的。例如:

protected final Object dynamicMethod(
com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,
Object arg0, Object arg1) {
switch (method) {
case NEW_MUTABLE_INSTANCE: {
return new com.google.cloud.speech.v1.StreamingRecognizeResponse();
}
case IS_INITIALIZED: { //**clicking on first error takes to this line.** but it is as solution suggests.
return DEFAULT_INSTANCE;
}
case MAKE_IMMUTABLE: {
results_.makeImmutable();
return null;
}
case NEW_BUILDER: {
return new Builder();
}
case VISIT: {...
...................

我无法再编译我的项目,我需要修复这个错误。任何解决此问题的建议都会有所帮助。

最佳答案

不清楚您指的是哪个 Java 示例,但是 com.google.protobuf enumeration GeneratedMessageLite.MethodToInvoke通常有这些常量:

Object dynamicMethod(MethodToInvoke method, Object arg0, Object arg1) {
switch (method) {
case GET_DEFAULT_INSTANCE: {
return DEFAULT_INSTANCE;
}
case GET_PARSER: {
break;
}
case IS_INITIALIZED: {
break;
}
case MAKE_IMMUTABLE: {
results_.makeImmutable();
return null;
}
case MERGE_FROM: {
break;
}
case NEW_BUILDER: {
return new Builder();
}
case NEW_INSTANCE: {
return new com.google.cloud.speech.v1.StreamingRecognizeResponse();
}
case PARSE_PARTIAL_FROM: {
break;
}
}
}

没有 NEW_MUTABLE_INSTANCE 也没有 VISIT。也可以列出它们:

for (GeneratedMessageLite.MethodToInvoke c : GeneratedMessageLite.MethodToInvoke.values()) {
System.out.println(c);
}

另见 StreamingRecognizeResponse .

关于android - cloud.speech.v1.StreamingRecognizeResponse - 错误 : an enum switch case label must be the unqualified name of an enumeration constant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59606918/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com