Reputation: 73
I am trying to setup Google protobuf with netty, but when I start compilation gradle first download google protobuf (at least at the first attempt) but then at compilation it just tells me :
/src/main/java/GameMoveOuterClass.java:1536: error: package com.google.protobuf.GeneratedMessageV3 does not exist
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
here is my build.gradle :
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(' '))
}
}
If someone knows what's wrong, please let me know Thanks
Upvotes: 4
Views: 10636
Reputation: 12177
In my scenario, both my app
and library
module should add
implementation 'com.google.protobuf:protobuf-javalite:3.9.1'
even app
has a dependency on library
Upvotes: 0
Reputation: 11515
You're using the version 2.4.1
of protobuf which doesn't come with GeneratedMessageV3
.
Update to a new version of protobuf which include this class like the 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'
}
Upvotes: 5
Reputation: 1476
I am not familiar with Gradle but it looks to me like you are mixing new protobuf generated code with an older protobuf library, which is not supported. The GeneratedMessageV3
class was added only recently (around 3.0 I believe), and so new generated code that references that class cannot be linked against an older library which does not include it.
Upvotes: 1
Reputation: 28099
Using the maven central advanced search for com.google.protobuf.GeneratedMessageV3
it seems that the class is in com.google.cloud:google-cloud-nio:xxx
or maybe com.trueaccord.scalapb:protobuf-runtime-scala_yyy:zzz
. I'm guessing you'll need to add one of these to your classpath.
Upvotes: 2