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
internaland API modules so features expose only a small public surface. - Convention plugins in a
build-logicmodule 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 invalues-hi,values-esand so on. Use plurals for counts and format arguments instead of joining text. - Support right-to-left languages (
start/endinstead ofleft/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
- Split a project into :app and :core:data modules.
- Add dev and production flavors and switch base URL.
- Add Hindi (or another language) strings and test the app in that language.
- 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.