![](/img/trans.png)
[英]How to resolve class file for com.google.cloud.Service not found
[英]class file for com.google.protobuf.MessageOrBuilder not found
我正在做我最后一年的項目,一個 android 應用程序,它涉及 firebase 和 dialogflow。 我有這個問題“找不到 com.google.protobuf.MessageOrBuilder 的類文件”。
這是我的應用程序 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'
}
這些是我遇到的錯誤:
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
*更新:dialogflow 依賴項與 firebase 依賴項發生沖突,這會導致我的應用程序連接到其 firebase 時出錯。
我希望你能幫助我。 謝謝你。
我剛剛開始使用 gRPC,但我可能遇到了同樣的問題,在我的例子中,它通過簡單地在 gradle 中添加以下依賴項來工作:
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
簡而言之,我的代碼沒有提供反序列化消息所需的 MessageOrBuilder 所需的依賴項。
我猜作者發現了這個問題(因為 11 個月過去了)。 但是,如果其他人有同樣的問題,我建議在 gradle 或 maven 上運行依賴樹,並檢查(子模塊?)是否具有 protobuf-java 依賴項(具有 MessageOrBuilder 類)。 我希望我有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.