Enterprise Android: Modules, WebSockets, i18n, Wear, TV, KMP

Android Development with Kotlin: 21 Real Projects · Production Android · 4 min read · Updated

Modules with clear edges

  1. The app module is thin. It connects the feature modules.
  2. Feature modules own their screens and logic.
  3. They depend on core modules, never on each other.
  4. Plain-Kotlin core code can later be shared with iOS using Kotlin Multiplatform.

Small apps can be one module with a few screens. Companies with large apps and many developers need more structure. This lesson is a tour of those practices, so you can recognise them in a job and know what to study next.

Multi-module and scalable code

  • Feature modules (:feature:cart) own their screens, ViewModels and tests. Core modules (:core:network, :core:database, :core:designsystem) are shared.
  • Use internal and API modules so features expose only a small public surface.
  • Convention plugins in a build-logic module share Gradle settings (compile SDK, Compose setup), so a new module takes a few lines.
  • Run tests per module and cache builds (Gradle build cache) so CI stays fast.
  • Feature flags (Remote Config or your own) let you merge unfinished work safely and turn features on gradually.

Multiple environments

Use build flavors (lesson 29) for dev, staging and production, each with its own base URL, Firebase project and logging level. Hilt provides the right values. Never let a debug build talk to production data by accident.

Real-time communication

WebSockets keep a two-way connection open, ideal for chat, live prices and collaborative apps. OkHttp supports them directly, and you can wrap the messages in a Flow.

fun socketMessages(url: String): Flow<String> = callbackFlow {
    val ws = client.newWebSocket(Request.Builder().url(url).build(), object : WebSocketListener() {
        override fun onMessage(webSocket: WebSocket, text: String) { trySend(text) }
        override fun onFailure(webSocket: WebSocket, t: Throwable, r: Response?) { close(t) }
    })
    awaitClose { ws.close(1000, null) }
}

Handle reconnection with a growing delay, and fall back to polling or push notifications when the app is in the background. WebRTC adds direct audio, video and data between devices (video calls). It needs a signalling server and STUN/TURN servers, and most teams use a managed SDK instead of building it.

Localisation and accessibility

  • Put every user-facing string in strings.xml; add translations in values-hi, values-es and so on. Use plurals for counts and format arguments instead of joining text.
  • Support right-to-left languages (start/end instead of left/right).
  • Format dates, numbers and currency with the user's locale.
  • Per-app language settings are available on newer Android versions.
  • Meet accessibility rules: labels, contrast, 48 dp touch targets, large font scaling, no information shown by colour alone, and full TalkBack support.

Other form factors

  • Foldables and tablets: use window size classes and adaptive layouts (list and detail side by side).
  • Wear OS: Compose for Wear OS, small round screens, short tasks, tiles and complications.
  • Android TV: remote and D-pad focus, large text, Leanback or Compose for TV.
  • Android Auto and Automotive: strict templates for safety; you build media or navigation experiences through approved APIs.

Kotlin Multiplatform

Kotlin Multiplatform (KMP) shares Kotlin code, such as networking, data and business rules, between Android and iOS (and desktop and web), while the UI can stay native or use Compose Multiplatform. It pairs naturally with this course: your ViewModels, repositories and use cases are plain Kotlin. Start by sharing one module, such as the API client, and grow from there.

App security audit

Before major releases, check dependencies for known vulnerabilities, review exported components, permissions, logging and stored data against the security lesson, and run a static analysis tool such as Android Lint and detekt.

Your task

  1. Split a project into :app and :core:data modules.
  2. Add dev and production flavors and switch base URL.
  3. Add Hindi (or another language) strings and test the app in that language.
  4. Make one screen show a list and detail side by side on a wide emulator.

How to check it worked

  • Each module builds and tests on its own.
  • The app is fully usable in a second language.
  • You can explain what KMP shares and what it does not.

Frequently asked questions

When do I need multiple modules?

When builds slow down, teams grow, or you want strict boundaries and reuse. A small app can stay in one module.

WebSocket or polling?

Use a WebSocket for live two-way updates while the app is open. Use polling or push for occasional updates and when the app is in the background.

Does Kotlin Multiplatform replace Android development?

No. It shares non-UI code between platforms. You still build and ship each platform's app.