Skip to content

benwicks/structured-data-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

structured-data-demo

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"

Download the sample Android app .apk

  • Go here to download the demo app

Presentation references

For further reference

How-to generate protobuf model from .proto message

Using Square's Wire library

  • 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

Using Google's protoc tool

  • 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

About

An Android application to demonstrate decoding/encoding data using a few different formats.

Resources

Stars

Watchers

Forks

Packages

No packages published