dead.fish
12/19/2025, 6:48 PMandroidTarget() with androidLibrary, splitting up the monolithic app module in app-<platform> modules, etc. One thing that I encountered, that I cannot quite wrap my head around, is that now with KGP 2.3 Robolectric-based Compose Android Tests fail with `MissingResourceException`s. I debugged into the issue and found that in ResourceReader.android.kt the resources can no longer be loaded via the following assets.open(...) call (something which worked with KGP 2.2):
private fun getResourceAsStream(path: String): InputStream {
return try {
assets.open(path)
} catch (e: FileNotFoundException) {
try {
instrumentedAssets.open(path)
} catch (e: FileNotFoundException) {
val classLoader = getClassLoader()
classLoader.getResourceAsStream(path) ?: throwMissingResourceException(path)
}
}
}
but ultimatively fall back onto classLoader.getResourceAsStream which also fails because the Robolectric SandboxClassLoader does not list the compose resource directories either. I tried to add
kotlin {
androidLibrary {
namespace = "..."
androidResources {
enable = true
}
}
}
to my Gradle configuration (even though I don't need compose / Android-based resources in production code, just in common code), but this did not help either. Any hints?
I created https://youtrack.jetbrains.com/issue/CMP-9452 for this.