0

解壓縮protobuf後,我的C:\Sooraj\Playdrone\android-checkin-master\src\main\protobuf\checkin.proto中有proto文件,java相關的源代碼位於C:\Sooraj\Playdrone\protobuf-2.6.1\java\src使用協議緩衝區編譯器從proto文件生成java文件 - Google API

當我嘗試執行:

protoc -I=C:/Sooraj/Playdrone/android-checkin-master /android-checkin-master/src/main/java/com/android/checkin --java_out=C:/Sooraj/P laydrone/dest C:/Sooraj/Playdrone/android-checkin-master/android-checkin-master /src/main/protobuf/checkin.proto" 

,我發現了以下錯誤:

C:/Sooraj/Playdrone/android-checkin-master/android-checkin-master/src/main/proto buf/checkin.proto: File does not reside within any path specified using --proto_ path (or -I). You must specify a --proto_path which encompasses this file. Not e that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equiv alent (it's harder than you think). 

所以,請幫助。我應該如何對我的項目執行protoc -I=$SRC_DIR --java_out=$DST_DIR $SRC_DIR/addressbook.proto命令。我有原始文件,並在谷歌開發人員網站$SRC_DIR意思是「你的應用程序的源代碼居住的地方」

我想我給了一切正確的事情。任何人都可以告訴如何執行protoc從proto文件生成java文件?

回答

0

-I標誌是這樣的:

-I=C:/Sooraj/Playdrone/android-checkin-master/android-checkin-master/src/main/java/com/android/checkin 

-I目的是指定您的.proto文件中找到(爲了解決這個文件裏面出現import語句)。該標誌是而不是意在指定您的Java文件所在的位置;這就是--java_out的用途。

但你.proto文件是這樣的:

C:/Sooraj/Playdrone/android-checkin-master/android-checkin-master/src/main/protobuf/checkin.proto 

這不是位於你-I指定的目錄。這就是錯誤試圖告訴你的。

也許,你想你的-I標誌更改爲:

-I=C:/Sooraj/Playdrone/android-checkin-master/android-checkin-master/src/main/protobuf 
相關問題