android - kotlin android 的 gRPC:导入“google/protobuf/wrappers.proto”不起作用
问题描述
我在https://github.com/grpc/grpc-java/tree/master/examples/example-kotlin/android/helloworld创建了一个与 kotlin android 项目的示例 gRPC 非常相似的 gRPC 项目
如果我使用示例 proto 文件,则构建过程有效。但是现在,我已经用不同的原始文件替换了原始文件,Gradle 无法构建我的项目。
这是失败的原型文件:
syntax = "proto3";
package tensorflow.serving;
option cc_enable_arenas = true;
import "google/protobuf/wrappers.proto";
// Metadata for an inference request such as the model name and version.
message ModelSpec {
// Required servable name.
string name = 1;
// Optional version.
google.protobuf.Int64Value version = 2;
// A named signature to evaluate. If unspecified, the default signature will
// be used.
string signature_name = 3;
}
错误信息是:
Cause: protoc: stdout: . stderr: app/build/extracted-include-protos/main: warning: directory does not exist.
app/build/extracted-include-protos/main: warning: directory does not exist.
app/src/debug/proto: warning: directory does not exist.
app/src/debug/proto: warning: directory does not exist.
google/protobuf/wrappers.proto: File not found.
model.proto: Import "google/protobuf/wrappers.proto" was not found or had errors.
model.proto:30:3: "google.protobuf.Int64Value" is not defined.
解决方案
普通 protobuf jar 附带的“知名”protos 不包含在 kotlin Android 示例正在使用的 protobuf-lite jar 中。该问题在https://github.com/protocolbuffers/protobuf/issues/1889中进行了跟踪
作为一种解决方法,您可以将普通 protobuf jar 中的 protos 添加到您的项目中:
dependencies {
protobuf 'com.google.protobuf:protobuf-java:3.5.1'
}
推荐阅读
- javascript - 最省时的路线
- kubernetes - Kubernetes 部署:获取可用且最新的 pod 数量
- azure-ad-b2c - Azure AD B2C 自动注销 - 使用 PKCE 的授权代码流 - 自定义策略 - msal
- javascript - 具有数组和对象的函数
- python - 从python中的每个组中获取前n个值?
- c# - 为什么 UserClaims 没有添加到 Asp.net 核心身份流中的身份验证 cookie
- html - 如何在不拉伸的情况下将图像调整为工具栏中的父元素?
- qt5 - 与桌面应用程序和 WebAssembly 应用程序不同的行为
- javascript - 反应原生错误的后退按钮行为
- angular - 命名路由器出口匹配但保持为空