---
title: "It’s a non-transitive R class world"
description: "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."
url: "https://swe.quest/articles/it-s-a-non-transitive-r-class-world-dc7be71b63e01554"
canonical: "https://slack.engineering/its-a-non-transitive-r-class-world/"
source: "Slack Engineering"
published: "2023-02-01"
difficulty: "medium"
kind: "Case study"
reading_minutes: 5
tags: ["mobile","build-systems","refactoring","static-analysis","developer-productivity"]
---

# It’s a non-transitive R class world

A post on [Slack Engineering](https://swe.quest/sources/slack.md), published 2023-02-01, 5 min read, Case study. Original: [https://slack.engineering/its-a-non-transitive-r-class-world/](https://slack.engineering/its-a-non-transitive-r-class-world/)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Static analysis](https://swe.quest/tags/static-analysis.md) (Engineering practices)
- [Developer productivity](https://swe.quest/tags/developer-productivity.md) (Engineering practices)

## Prerequisites

- Android resources and R classes ([easy posts on Mobile](https://swe.quest/tags/mobile.md?difficulty=easy))
- Gradle multi-module builds
- Kotlin import aliases ([easy posts on Java & JVM](https://swe.quest/tags/jvm.md?difficulty=easy))

## Keywords

Android Gradle Plugin, nonTransitiveRClass, Android Studio, Kotlin, Android Lint

## Related posts

- [Scaling Slack’s Mobile Codebases: Modularization](https://swe.quest/articles/scaling-slack-s-mobile-codebases-modularization-70662aadd976d6a5.md): Slack Engineering · 2022-03-28 · Medium · 11 min read · Mobile, Build systems, Refactoring & migrations, Developer productivity, Swift
  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.
- [Scaling Slack’s Mobile Codebases: Modernization](https://swe.quest/articles/scaling-slack-s-mobile-codebases-modernization-950b9c539d5b5770.md): Slack Engineering · 2022-05-04 · Medium · 12 min read · Mobile, Refactoring & migrations, Swift, Java & JVM, Build systems
  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.
- [From zero to 10 million lines of Kotlin](https://swe.quest/articles/from-zero-to-10-million-lines-of-kotlin-e0f9a5140a87605f.md): Meta Engineering · 2022-10-24 · Medium · 13 min read · Java & JVM, Refactoring & migrations, Mobile, Developer tools
  Meta has converted its Android codebase to over 10 million lines of Kotlin by wrapping JetBrains' J2K converter in an automated pipeline called Kotlinator.
- [Stabilize, Modularize, Modernize: Scaling Slack’s Mobile Codebases](https://swe.quest/articles/stabilize-modularize-modernize-scaling-slack-s-mobile-codebases-6744c42390a79288.md): Slack Engineering · 2022-01-12 · Easy · 14 min read · Mobile, Refactoring & migrations, Swift, Java & JVM, Developer productivity
  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.
- [Enabling Kotlin incremental compilation on Buck2](https://swe.quest/articles/enabling-kotlin-incremental-compilation-on-buck2-bd5307852c0570ff.md): Meta Engineering · 2025-08-26 · Medium · 10 min read · Build systems, Java & JVM, Compilers, Developer productivity, Mobile
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
