SwiggyBalvinder GambhirProblem & solution
How Swiggy Migrated from protobuf-java to Square Wire
Summary
Swiggy migrated from protobuf-java to Square Wire after profiling showed that the runtime and protoc-generated code consumed 6.735 MB of Android app size. protobuf-javalite was rejected because Swiggy relies extensively on google.protobuf.Any, while Wire retained support for Any and other well-known types with a smaller runtime and immutable Kotlin models. The migration required updating snake_case property access, message construction, serialization calls, ProGuard rules, and a custom pipeline that compiled all schemas together before publishing package-specific AARs to AWS CodeArtifact. The team also fixed repeated enum fields with [packed = true] after discovering a silent wire-format mismatch. It reduced Swiggy’s app size by 3.52 MB and produced measurable reductions for Instamart and Toing.
Context
Swiggy found that protobuf-java and protoc-generated code consumed 6.735 MB of Android app size. protobuf-javalite was unsuitable because the app uses google.protobuf.Any extensively, and its runtime omits Any and other well-known types.
Approach / What changed
Swiggy replaced protobuf-java with Square Wire, updating field access, message construction, encoding and decoding, and ProGuard configuration. A custom pipeline compiles the complete schema set in one pass, rebuilds changed packages and transitive dependents, creates package-specific AARs, and publishes them to AWS CodeArtifact.
Takeaways
Wire generates immutable Kotlin models with constructors and copy(), replacing protobuf-java’s Java builders and reducing generated-code overhead.
Repeated enum fields required an explicit [packed = true] annotation in the .proto files because Wire otherwise encoded them unpacked, causing silent wire-format mismatches.
R8 rules must preserve Wire’s reflective ADAPTER fields, @WireField annotations, enum fromValue(int) methods, and selected Companion names for JSON serialization to work.
Source and freshness
- Source
- medium.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.