Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android and Protocol Buffers

I am writing an Android application that would both store data and communicate with a server using protocol buffers. However, the stock implementation of protocol buffers compiled with the LITE flag (in both the JAR library and the generated .java files) has an overhead of ~30 KB, where the program itself is only ~30 KB. In other words, protocol buffers doubled the program size.

Searching online, I found a reference to an Android specific implementation. Unfortunately, there seems to be no documentation for it, and the code generated from the standard .proto file is incompatible with it. Has anyone used it? How do I generate code from a .proto file for this implementation? Are there any other lightweight alternatives?

like image 835
kwogger Avatar asked Nov 12 '09 16:11

kwogger


2 Answers

I know it's not a direct answer to your question, but an extra 30kb doesn't sound that bad to me. Even on EDGE that'll only take an extra 1 to 2 seconds to download. And memory is tight on android, but not THAT tight -- 30 kb is only about 1/10th of one percent of the available application memory space.

like image 138
emmby Avatar answered Oct 20 '22 03:10

emmby


Are there any other lightweight alternatives?

I'm taking this to mean "to using protocol buffers", rather than "for using protocol buffers with an Android application". I apologise if you are already commited to protocol buffers.

This site is about "comparing serialization performance and other aspects of serialization libraries on the JVM". You'll find many alternatives listed there.

While there is no mention of the memory footprint of the different implementations at the moment I am sure it is a metric which the people on the wiki would be interested in.

like image 30
davetapley Avatar answered Oct 20 '22 01:10

davetapley