Feng Xiao | 7d55040 | 2018-04-12 17:58:55 -0700 | [diff] [blame] | 1 | # Protocol Buffers - Google's data interchange format |
| 2 | |
| 3 | Copyright 2008 Google Inc. |
| 4 | |
| 5 | https://developers.google.com/protocol-buffers/ |
| 6 | |
| 7 | ## Use Protobuf Java Lite Runtime |
| 8 | |
| 9 | Protobuf Java Lite runtime is separated from the main Java runtime because |
| 10 | it's designed/implemented with different constraints. In particular, Java |
| 11 | Lite runtime has a much smaller code size which makes it more suitable to |
| 12 | be used on Android. |
| 13 | |
Hao Nguyen | 1da2a67 | 2019-04-09 13:07:25 -0700 | [diff] [blame] | 14 | Note that in order to achieve maximum performance and code size, we will |
| 15 | NOT guarantee API/ABI stability for Java Lite. If this is not acceptable |
| 16 | for your use-case, please use the full Java runtime instead. Note that |
| 17 | the latest version of Java Lite is not compatible with the 3.0.0 version. |
Feng Xiao | 7d55040 | 2018-04-12 17:58:55 -0700 | [diff] [blame] | 18 | |
Hao Nguyen | 1da2a67 | 2019-04-09 13:07:25 -0700 | [diff] [blame] | 19 | You can generate Java Lite code for your .proto files: |
Feng Xiao | 7d55040 | 2018-04-12 17:58:55 -0700 | [diff] [blame] | 20 | |
Hao Nguyen | 1da2a67 | 2019-04-09 13:07:25 -0700 | [diff] [blame] | 21 | $ protoc --java_out=lite:${OUTPUT_DIR} path/to/your/proto/file |
Feng Xiao | 7d55040 | 2018-04-12 17:58:55 -0700 | [diff] [blame] | 22 | |
Hao Nguyen | 1da2a67 | 2019-04-09 13:07:25 -0700 | [diff] [blame] | 23 | Note that "optimize_for = LITE_RUNTIME" option in proto file is deprecated |
| 24 | and will not have any effect any more. |
Feng Xiao | 7d55040 | 2018-04-12 17:58:55 -0700 | [diff] [blame] | 25 | |
Hao Nguyen | cf9fe72 | 2019-05-08 17:05:58 -0700 | [diff] [blame] | 26 | Include the generated Java files in your project and add a dependency on the |
| 27 | protobuf Java runtime. If you are using Maven, use the following: |
| 28 | |
| 29 | ```xml |
| 30 | <dependency> |
| 31 | <groupId>com.google.protobuf</groupId> |
| 32 | <artifactId>protobuf-javalite</artifactId> |
| 33 | <version>3.8.0</version> |
| 34 | </dependency> |
| 35 | ``` |
Hao Nguyen | 92e824e | 2019-04-09 15:07:44 -0700 | [diff] [blame] | 36 | |
| 37 | For the older version of Java Lite (v3.0.0), please refer to: |
| 38 | |
| 39 | https://github.com/protocolbuffers/protobuf/blob/javalite/java/lite.md |