PUBLIC OBJECT

Protocol Buffers on Android

The Facebook folks recently posted about how they went through tremendous effort to squeeze their big fat app into Gingerbread's Dalvik VM.  One of the most fattening things Android apps use is protocol buffers. They were designed & optimized for desktop Java, which is much more forgiving when it comes to bloated and obese applications.

If you're using protocol buffers on Android, don't bother with the LITE_RUNTIME. For the schema I studied it was only about 20% smaller than the default speed-optimized protos.

Instead, you should use protobuf-j2me. It's 80% smaller. It's also fast: in my measurements there was no noticeable difference in speed between the standard protos and protobuf-j2me.

The one drawback of protobuf-j2me is that it's designed for an ancient, horse-and-buggy version of Java that doesn't support generics or modern collection types.