Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Slack Engineering 5 min read Case study mediumAdept

It’s a non-transitive R class world

Slack migrated its 400+ module Android codebase to non-transitive R classes, where each module's R class contains only its own resources, yielding ~14% faster incremental builds after resource or layout changes and an ~8.5% (about 5.5MB) APK/DEX size reduction. Because Android Studio's built-in migration refactor stalled at this scale, the team used regex find-and-replace on the two modules holding most resources, a script to add Kotlin import aliases (e.g. L10nR, SlackKitR), and then enabled android.nonTransitiveRClass and android.enableAppCompileTimeRClass. Shared live templates and three auto-fixing lint checks enforce consistent alias conventions, and the migration also exposed misplaced resources and made resource origins easier to trace.

Assumes: Android resources and R classesGradle multi-module buildsKotlin import aliases

Related posts

  • Scaling Slack’s Mobile Codebases: Modularization

    Slack Engineering mediumAdept

    Slack split its monolithic iOS and Android app targets into owned Feature, Service and Library modules with strict linking rules, such as interface/implementation pairs on iOS, to cut build times, untangle dependencies and clarify code ownership. On iOS, adopting Bazel made module creation easy, eliminated project-file merge conflicts, enabled static linking that improved pre-main launch time, and powered code generation for modules, CoreData models and feature flags. On Android, Slack abandoned a per-module Dagger 'graph of graphs' in favor of Square's Anvil, cut KAPT usage by moving to KSP, Moshi and Kotlin data classes, and enabled Gradle configuration caching, saving 20-45s on builds after configuration changes.

  • Scaling Slack’s Mobile Codebases: Modernization

    Slack Engineering mediumAdept

    Slack's year-and-a-half Duplo initiative concluded by modernizing its iOS and Android codebases: iOS moved to a custom VIPER-style feature architecture, stricter SwiftLint rules banning singletons and NotificationCenter, Combine (via CombineX until iOS 12 was dropped), and broader SlackKit adoption, while Android replaced Gson with Moshi, Android Priority Job Queue with WorkManager, and handwritten API calls with an internal Retrofit-based library, and introduced coroutines and Compose incrementally. iOS ended 68% modernized and 81% modularized with CI stability rising from 77% to 90% and average time-to-merge down 64%, Android reached 92% modularization, and local builds later dropped nearly 50% with Bazel and M1 Macs. Follow-up work includes layered module dependency rules to stop circular dependencies, possibly adopting Needle for dependency injection, and splitting Android modules into API/implementation pairs for build parallelism.

  • From zero to 10 million lines of Kotlin

    Meta Engineering mediumAdept

    Meta has converted its Android codebase to over 10 million lines of Kotlin by wrapping JetBrains' J2K converter in an automated pipeline called Kotlinator. The pipeline preprocesses Java packages, runs J2K headlessly through Android Studio, then applies automated refactors and linters built on the Kotlin compiler's PSI AST. Those refactors fix issues such as JUnit @Rule annotations needing @JvmField or @get:Rule, and replace TextUtils.isEmpty with isNullOrEmpty. Meta chose a full conversion over Kotlin-for-new-code-only to avoid platform-type null risks from Java interop. Results: about 11% fewer lines, no runtime performance regression in A/B tests, negligible APK size impact after Proguard/Redex, and longer build times as the main cost.

  • Stabilize, Modularize, Modernize: Scaling Slack’s Mobile Codebases

    Slack Engineering easyNovice

    Slack chose to refactor its iOS and Android codebases in place through Project Duplo, a cross-platform effort in three phases: Stabilization, Modularization and Modernization. A full rewrite and shared cross-platform code (React Native, Flutter, C++, Kotlin Multiplatform) were rejected because of risk, performance and tooling costs. The six-month Stabilization phase used a dedicated core team to finish stalled migrations. On iOS that meant porting about 80,000 lines of Objective-C to Swift and fully adopting internal data-access and networking libraries. On Android it meant splitting the monolithic SlackApi and database interfaces, moving queries to SQLDelight, standardizing on the repository pattern and removing Otto bus events.

  • Enabling Kotlin incremental compilation on Buck2

    Meta Engineering mediumAdept

    Meta integrated the Kotlin incremental compiler into Buck2 via Kotlin's experimental Build Tools API, making some large Android modules build up to 3x faster and improving incremental build times about 30% for the average developer. The work involved migrating the toolchain to the shaded kotlin-compiler-embeddable, using Buck2 incremental actions to keep prior outputs and compute changed-file lists from input hashes, making the cache relocatable for remote execution, and generating classpath snapshots as a separate cacheable action. Custom compiler plugins had to be made incremental and accumulate results across multiple compilation rounds. jvm-abi-gen still lacks incremental support, so a stopgap merges the new ABI with the previous output.

The quest for software engineering knowledge.

Look:
Layout: