An Android application that demonstrates decoding/encoding data with XML, JSON, and protocol buffers.
I gave a talk at the Omaha Google Developers' Group on "Decoding/Encoding Structured Data with Android"
- Go here to download the demo app
- All about Protocol Buffers
- Did you know that, according to Google, you can decrease the amount of data you send by 3-10x and increase parsing speeds by 20-100x, simply by changing the data format your app uses to transfer data?
- "Extending a Protocol Buffer"
- proto2 Language Guide
- Encoding implementation details
- Android's XML recommendation
- Square's Wire blog post
- FlatBuffers, another format developed by Google similar to protobufs that is intended for game development
- Performance Patterns video about protocol buffers on Android
- Checkout this source and open in as a new project in Android Studio
- Go to the wire project on github and look at its README
- Download the latest wire-compiler from maven.org
- Open a shell prompt and change to the structured-data-demo directory
- Run
java -jar ~/Downloads/wire-compiler-2.1.1-jar-with-dependencies.jar --proto_path=app/src/main/proto/benjaminwicks/structureddatademo/model/protobuf/wire/ --java_out=app/out_wire SpeciesList.proto
to generate a Java class from the .proto file (Resulting class was 623 lines) - Copy the generated Java class from the out_wire directory to the matching directory within the project's java directory
- Download the latest source from Google's download page
- Unzip and look at the README. Follow the steps to install protoc
- Run
protoc --java_out=app/out_google -I=app/src/main/proto app/src/main/proto/benjaminwicks/structureddatademo/model/protobuf/google/SpeciesList.proto
to generate a Java class from the .proto file (Resulting class was 3581 lines)- See the output here
- Or, follow Google's Protobuf guidelines for Android and use the protoc gradle plugin to generate a "Nano" Java class (Resulting class was 442 lines)
- See the output here
- Copy the generated Java class from the out_google directory to the matching directory within the project's java directory