2016-11-26 180 views
0

我想用netty設置Google protobuf,但是當我開始編譯gradle時,首先下載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 

這裏是我的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(' ')) 
    } 
} 

如果有人知道什麼是錯的,請讓我知道 感謝

回答

0

使用日e maven central advanced search for com.google.protobuf.GeneratedMessageV3看來該班級在com.google.cloud:google-cloud-nio:xxxcom.trueaccord.scalapb:protobuf-runtime-scala_yyy:zzz。我猜你需要將其中的一個添加到你的類路徑中。

0

我對Gradle並不熟悉,但是在我看來,您似乎正在將新的protobuf生成的代碼與舊的protobuf庫混合,這是不受支持的。 GeneratedMessageV3類最近才添加(我相信大約3.0),所以引用該類的新生成的代碼不能與不包含它的舊庫鏈接。

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' 
}