gpt4 book ai didi

android - 用于 kotlin android 的 gRPC : Import "google/protobuf/wrappers.proto" does not work

转载 作者:行者123 更新时间:2023-11-29 23:31:02 24 4
gpt4 key购买 nike

我在 https://github.com/grpc/grpc-java/tree/master/examples/example-kotlin/android/helloworld

如果我使用示例 proto 文件,则构建过程有效。但是现在,我已经用不同的协议(protocol)文件替换了协议(protocol)文件,Gradle 无法构建我的项目。

这是失败的原型(prototype)文件:

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 附带的“知名”proto 不包含在 kotlin Android 示例使用的 protobuf-lite jar 中。在 https://github.com/protocolbuffers/protobuf/issues/1889 中跟踪了该问题

作为解决方法,您可以将普通 protobuf jar 中的 proto 添加到您的项目中:

dependencies {
protobuf 'com.google.protobuf:protobuf-java:3.5.1'
}

关于android - 用于 kotlin android 的 gRPC : Import "google/protobuf/wrappers.proto" does not work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52661463/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com