Compose Multiplatform Shared Resources: The Traps That Sabotage Your Release
Any team shipping a KMP app with shared UI needs to know where composeResources diverges from Android's resource system, because a single SVG or locale request without a fallback can break a release across targets.
Compose Multiplatform lets a shared UI module load images, fonts, and strings from commonMain/composeResources, with the Gradle plugin generating a type-safe Res class. The resource library handles language, dark mode, and density via directory qualifiers, so a single composable can adapt across platforms without explicit checks. Most of the setup is straightforward, but several edge cases turn into release-blocking failures.
The generated accessors are extension properties, so importing Res alone does not resolve concrete resources like Res.drawable.brand_logo; each specific import must be present. The painterResource and Font functions come from org.jetbrains.compose.resources, not the Android-only package, and Font is composable. For localization, keeping a bare values-zh directory is mandatory when supporting both Simplified and Traditional Chinese, because Android and desktop sometimes request only zh, leaving only zh-Hans and zh-Hant as ambiguous matches that throw an exception.
Platform gaps also matter. SVG images are not supported on Android, and vector XML copied from Android projects may reference @color/ or ?attr/ values that the shared resource library cannot resolve. The files directory supports no qualifiers and no type-safe accessors; use Res.readBytes for small data or Res.getUri for media. On Web, painterResource returns an empty Painter on first composition, so reserving image dimensions prevents layout jumps. Dark mode and locale switching require platform-level environment changes; modifying MaterialTheme alone does not alter the resource environment.
The resource library's qualifier handling is a strict subset of Android's, so teams that copy Android res layouts will hit silent mismatches until runtime.
The mandatory zh fallback exposes a naive script-matching model, where multi-script locales need an explicit default path to avoid ambiguous resolution.
The lack of SVG support on Android is a practical reminder that Compose Multiplatform is not a drop-in replacement for Android's resource system.
Resource environment changes stay platform-specific, so shared UI code cannot assume that theme state alone propagates to resource selection.