简体   繁体   English

找不到 com.google.protobuf.MessageOrBuilder 的 class 文件

[英]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.

相关问题 如何解决 class 文件 com.google.cloud.Service not found - How to resolve class file for com.google.cloud.Service not found AbstractGoogleClientRequest 和 GoogleClientRequestInitializer class 在 com.google.api-client:google-api-client-android:2.0.0 中找不到 - AbstractGoogleClientRequest and GoogleClientRequestInitializer class not found in com.google.api-client:google-api-client-android:2.0.0 Flutter 找不到 com.google.android.gms.providerinstaller.dynamite 的本地模块描述符 class - Flutter Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found 找不到 ID 为“com.google.gms.google-services”的插件 - Plugin with id 'com.google.gms.google-services' not found W/DynamiteModule:找不到 com.google.firebase.auth 的本地模块描述符类 - W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found 在 Android 中与 Firebase 连接时出错 找不到 com.google.firebase.auth 的本地模块描述符 class - Error Connecting with Firebase in Android Local module descriptor class for com.google.firebase.auth not found 找不到框架 Protobuf - Framework not found Protobuf 如何调查/修复:模糊导入:在多个模块中找到 package cloud.google.com/go/compute/metadata - How to investigate/fix: ambiguous import: found package cloud.google.com/go/compute/metadata in multiple modules Marshal/Unmarshal google.protobuf.Any proto 消息 - Marshal/Unmarshal google.protobuf.Any proto message 找不到 ID 为“com.google.gms.google-services”的插件。 [ Android ] - Plugin with id 'com.google.gms.google-services' not found. [ Android ]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM