Why Meta Is Shifting Android Development from Java to Kotlin—and What It Means for You

Meta’s recent blog reveals its large‑scale migration of Android apps from Java to Kotlin, highlighting Kotlin’s advantages, the challenges of mixed codebases, tooling updates, and the strategic decision to convert most of its 10 million‑line codebase, offering valuable lessons for mobile developers.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Why Meta Is Shifting Android Development from Java to Kotlin—and What It Means for You

Meta published a blog post describing its ongoing migration of Android applications from Java to Kotlin, sharing experiences and lessons learned.

The company argues that Kotlin, a popular Android language, offers key benefits over Java such as null‑safety, functional programming features, more concise code, and DSL/type‑safe builders. In the 2022 Stack Overflow developer survey, Kotlin’s favorability exceeds Java’s.

Meta compared the latest Kotlin release with Java 11 (the newest Java version usable for Android) and highlighted these advantages. Facebook engineers report that several Meta Android apps—including Facebook, Instagram, Messenger, Portal, and Quest—have already switched to Kotlin, with over one million lines of Kotlin code in each of Facebook, Messenger, and Instagram, and a total of more than ten million Kotlin lines across Meta’s Android codebase. As part of the migration, Meta is open‑sourcing various examples and utilities for handling Kotlin code.

However, the blog also notes drawbacks: mixed Java/Kotlin codebases require prolonged maintenance, Kotlin’s ecosystem has fewer tools than Java, and interoperability adds complexity. Build times are longer because Kotlin’s compiler and ecosystem are newer and less optimized than Java’s two‑decade‑long evolution.

How to Handle Migration

Meta says migration to Kotlin is both simple and complex. Kotlin’s design allows straightforward Java‑to‑Kotlin conversion and provides thoughtful interoperability, enabling JetBrains to offer J2K (the Java‑to‑Kotlin converter in IntelliJ/Android Studio). Yet J2K is not a silver bullet; some migration scenarios remain intricate.

Two Options Before Migration

Meta considered two strategies: (1) write new code in Kotlin while keeping most existing code in Java, or (2) attempt to convert almost all internal code to Kotlin.

The first option reduces work but introduces platform types that weaken Kotlin’s static safety, can cause runtime null‑pointer crashes, and leads to overload resolution differences between Kotlin and Java. For example, Kotlin code calling a Java‑implemented Kotlin interface can encounter null‑safety issues, and Java cannot mark type parameters as nullable (until recent fixes).

The second option faces the challenge that most of Meta’s code is Java, limiting developers’ ability to fully enjoy Kotlin’s benefits. Converting large codebases is labor‑intensive, and tools had to be updated (e.g., Redex to support new bytecode patterns, internal libraries relying on compile‑time bytecode transformation). Meta built custom solutions, updated Pygments for Kotlin syntax highlighting, and created Ktfmt—a deterministic Kotlin formatter based on google‑java‑format.

After preparing these tools, Meta began bulk conversion. Over 10 million lines of Kotlin have been added, and the overall codebase size shrank by about 11 %. The migration is still accelerating; any Android developer at Meta can now opt to use Kotlin, with tooling provided to ease conversion. While Kotlin still lacks some Java‑level tools and optimizations, Meta continues to close those gaps and plans to share improvements with the community.

For more details, see the official blog: https://engineering.fb.com/2022/10/24/android/android-java-kotlin-migration/

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavamigrationMobile DevelopmentAndroidKotlinMeta
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.