2018-04-13 00:58:55 +00:00
|
|
|
# Protocol Buffers - Google's data interchange format
|
|
|
|
|
|
|
|
Copyright 2008 Google Inc.
|
|
|
|
|
|
|
|
https://developers.google.com/protocol-buffers/
|
|
|
|
|
|
|
|
## Use Protobuf Java Lite Runtime
|
|
|
|
|
|
|
|
Protobuf Java Lite runtime is separated from the main Java runtime because
|
|
|
|
it's designed/implemented with different constraints. In particular, Java
|
|
|
|
Lite runtime has a much smaller code size which makes it more suitable to
|
|
|
|
be used on Android.
|
|
|
|
|
2019-04-09 20:07:25 +00:00
|
|
|
Note that in order to achieve maximum performance and code size, we will
|
|
|
|
NOT guarantee API/ABI stability for Java Lite. If this is not acceptable
|
|
|
|
for your use-case, please use the full Java runtime instead. Note that
|
|
|
|
the latest version of Java Lite is not compatible with the 3.0.0 version.
|
2018-04-13 00:58:55 +00:00
|
|
|
|
2019-04-09 20:07:25 +00:00
|
|
|
You can generate Java Lite code for your .proto files:
|
2018-04-13 00:58:55 +00:00
|
|
|
|
2019-04-09 20:07:25 +00:00
|
|
|
$ protoc --java_out=lite:${OUTPUT_DIR} path/to/your/proto/file
|
2018-04-13 00:58:55 +00:00
|
|
|
|
2019-04-09 20:07:25 +00:00
|
|
|
Note that "optimize_for = LITE_RUNTIME" option in proto file is deprecated
|
|
|
|
and will not have any effect any more.
|
2018-04-13 00:58:55 +00:00
|
|
|
|
2019-05-09 00:05:58 +00:00
|
|
|
Include the generated Java files in your project and add a dependency on the
|
|
|
|
protobuf Java runtime. If you are using Maven, use the following:
|
|
|
|
|
|
|
|
```xml
|
|
|
|
<dependency>
|
|
|
|
<groupId>com.google.protobuf</groupId>
|
|
|
|
<artifactId>protobuf-javalite</artifactId>
|
2019-08-30 13:42:28 +00:00
|
|
|
<version>3.9.1</version>
|
2019-05-09 00:05:58 +00:00
|
|
|
</dependency>
|
|
|
|
```
|
2019-04-09 22:07:44 +00:00
|
|
|
|
|
|
|
For the older version of Java Lite (v3.0.0), please refer to:
|
|
|
|
|
|
|
|
https://github.com/protocolbuffers/protobuf/blob/javalite/java/lite.md
|