我一年前用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: {...
...................
我无法再编译项目,我需要修复此错误。解决该问题的任何建议都会有所帮助。
Class GeneratedMessageLite.MethodToInvoke
而是具有这些枚举常量:
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
。