Hi all, I'm in the process of updating KGP 2.2 to ...
# multiplatform
d
Hi all, I'm in the process of updating KGP 2.2 to 2.3 and did the adaptions that are required to satisfy the future AGP compatibility, i.e. replacing
androidTarget()
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):
Copy code
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
Copy code
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.