OkHttp 4 Goes Kotlin
Article Summary
Jesse Wilson from Square just rewrote 25,000 lines of Java code in Kotlin without changing a single feature or fixing a single bug. Here's why that matters for your Android app.
OkHttp, one of the most widely used HTTP clients for Android and Java, released version 4.0 with its entire codebase converted from Java to Kotlin. Square's team prioritized maintaining complete compatibility while modernizing their foundation for future growth.
Key Takeaways
- 25K lines of Java converted to Kotlin with zero API changes
- Full binary and source compatibility maintained using japicmp enforcement
- Adds 1.2 MiB Kotlin stdlib dependency, reduced with ProGuard/R8
- Kotlin-facing APIs updated to use Kotlin idioms, breaking source compatibility
- Same minimum requirements: Android 5+ and Java 8+
OkHttp 4.0 proves you can modernize a massive codebase to Kotlin while maintaining perfect backward compatibility for Java users.
About This Article
Square needed to update OkHttp's foundation while keeping it stable and compatible for the millions of Java developers using it.
Jesse Wilson's team used japicmp to check that binary compatibility stayed intact and ran the same test suite throughout the Kotlin migration to catch any unexpected changes.
OkHttp 4.0 added a 1.2 MiB Kotlin stdlib dependency that gets much smaller when you use ProGuard or R8 optimization, so the library can grow without breaking existing Java applications.