Java 格拉德尔没有';找不到Google Protobuf包

Java 格拉德尔没有';找不到Google Protobuf包,java,gradle,protocol-buffers,Java,Gradle,Protocol Buffers,我正试图用netty设置Google protobuf,但当我开始编译时,gradle首先下载Google protobuf(至少在第一次尝试时),但在编译时它只告诉我: /src/main/java/GameMoveOuterClass.java:1536: error: package com.google.protobuf.GeneratedMessageV3 does not exist com.google.protobuf.GeneratedMessageV3.FieldAcce

我正试图用netty设置Google protobuf,但当我开始编译时,gradle首先下载Google protobuf(至少在第一次尝试时),但在编译时它只告诉我:

  /src/main/java/GameMoveOuterClass.java:1536: error: package com.google.protobuf.GeneratedMessageV3 does not exist
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
这是我的身材。格雷德尔:

apply plugin: 'java'
apply plugin: 'com.google.protobuf'

repositories {
    mavenCentral()
}

buildscript {
    repositories {
        mavenCentral()
   }
    dependencies {
        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0'
    }
}

dependencies {
    compile group: 'io.netty', name: 'netty-all', version: '4.1.5.Final'
    compile group: 'com.google.protobuf', name: 'protobuf-java', version: '2.4.1'
}


jar {
    manifest {
        attributes("Main-Class": 'server.Server',
        "Class-Path": configurations.compile.collect { it.getPath() }.join(' '))
    }
}
如果有人知道怎么了,请告诉我
感谢使用for
com.google.protobuf.GeneratedMessageV3
类似乎位于
com.google.cloud:google cloud nio:xxx
或者
com.trueaccord.scalapb:protobuf-runtime-scala_yyy:zzz
。我猜您需要将其中一个添加到您的类路径中。

我对Gradle不熟悉,但在我看来,您正在将新的protobuf生成的代码与旧的protobuf库混合,而旧的protobuf库不受支持。
GeneratedMessageV3
类是最近才添加的(我相信大约是3.0),因此引用该类的新生成代码无法与不包含该类的旧库链接。

您使用的是protobuf的版本
2.4.1
,它不随
GeneratedMessageV3
一起提供

更新到protobuf的新版本,其中包括该类,如
3.0.0

dependencies {
    compile group: 'io.netty', name: 'netty-all', version: '4.1.5.Final'
   compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.0.0'
}

在我的场景中,我的
应用程序
模块都应该添加

implementation 'com.google.protobuf:protobuf-javalite:3.9.1'
甚至
app
也依赖于
library