解壓縮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文件?