首页 > 解决方案 > Protobuf android:迁移到 AndroidX:找不到符号类 EnumVerifier

问题描述

我正在将现有项目迁移到 AndroidX。

当我尝试运行该应用程序时,我从“com.google.protobuf.Internal.java”中收到“错误:找不到符号类 EnumVerifier”。所以我签入了自动生成的文件“Internal.java”并且那里缺少“EnumVerifier”。

以下是我的 gradle 设置:

protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.8.0'
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}}}}}

dependancy {
implementation 'com.google.protobuf:protobuf-javalite:3.8.0'
}

//Android level gradle
dependancy {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.10'
}

提前致谢。

标签: javaandroidprotocol-buffersandroidx

解决方案


我遇到了同样的错误,在我的情况下,问题是“lite”版本,我替换了:implementation 'io.grpc:grpc-protobuf-lite:1.25.0'for implementation 'io.grpc:grpc-protobuf:1.25.0':,它编译和部署都很好。


推荐阅读