[英]class file for com.google.protobuf.MessageOrBuilder not found
I was working on my final year project, an android app which involves both firebase and dialogflow.我正在做我最后一年的项目,一个 android 应用程序,它涉及 firebase 和 dialogflow。 I have this problem of "class file for com.google.protobuf.MessageOrBuilder not found".
我有这个问题“找不到 com.google.protobuf.MessageOrBuilder 的类文件”。
This is my app gradle code:这是我的应用程序 gradle 代码:
android{
..
..
configurations.all {
exclude group:'com.google.api.grpc',module:'proto-google-common-protos'
exclude group: 'com.google.protobuf'
//exclude group: 'com.google.guava',module: 'guava-jdk5'
}
packagingOptions {
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/DEPENDENCIES'
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies{
..
..
//dialogflow
implementation 'com.google.cloud:google-cloud-dialogflow:2.1.0'
implementation 'io.grpc:grpc-okhttp:1.30.0'
}
These are the errors that I faced:这些是我遇到的错误:
error: cannot access MessageOrBuilder
.setText(TextInput.newBuilder().setText(message).setLanguageCode("en-US")).build();
^
class file for com.google.protobuf.MessageOrBuilder not found
error: cannot access GeneratedMessageV3
QueryInput input = QueryInput.newBuilder()
^
class file for com.google.protobuf.GeneratedMessageV3 not found
error: cannot access Builder
.setText(TextInput.newBuilder().setText(message).setLanguageCode("en-US")).build();
^
class file for com.google.protobuf.GeneratedMessageV3$Builder not found
*Update: The dialogflow dependencies clashes with firebase dependencies, which causes an error for my app to connect to its firebase. *更新:dialogflow 依赖项与 firebase 依赖项发生冲突,这会导致我的应用程序连接到其 firebase 时出错。
I hope u can help me.我希望你能帮助我。 Thank you.
谢谢你。
I am just starting to work with gRPC, but i may have had the same issue and in my case it worked by simply adding in gradle the below dependency:我刚刚开始使用 gRPC,但我可能遇到了同样的问题,在我的例子中,它通过简单地在 gradle 中添加以下依赖项来工作:
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
Simply put, my code did not have the required dependency that provided MessageOrBuilder, which is needed to deserialize the message.简而言之,我的代码没有提供反序列化消息所需的 MessageOrBuilder 所需的依赖项。
I guess author found the issue (since 11 months passed).我猜作者发现了这个问题(因为 11 个月过去了)。 However if someone else has the same issue I propose to run a dependency tree on gradle or maven and check if the (sub-module?) has the protobuf-java dependency (which has the MessageOrBuilder class).
但是,如果其他人有同样的问题,我建议在 gradle 或 maven 上运行依赖树,并检查(子模块?)是否具有 protobuf-java 依赖项(具有 MessageOrBuilder 类)。 I hope i helped.
我希望我有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.