Closed sereden closed 1 month ago
I'm getting a similar problem but with fonts
Config:
compose-plugin = "1.6.10"
kotlin = "2.0.0"
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }
// res config:
compose.resources {
publicResClass = true
packageOfResClass = "sample.resources"
generateResClass = always
}
Code to expose font:
@Composable
public fun workSans(): FontFamily {
return FontFamily(Font(Res.font.worksans_default))
}
Caused by: java.lang.IllegalStateException:
Unable to load font Font(assetManager, path=composeResources/sample.resources/font/worksans-default.ttf, weight=FontWeight(weight=400), style=Normal)
at androidx.compose.ui.text.font.FontListFontFamilyTypefaceAdapterKt.firstImmediatelyAvailable(FontListFontFamilyTypefaceAdapter.kt:195)
at androidx.compose.ui.text.font.FontListFontFamilyTypefaceAdapterKt.access$firstImmediatelyAvailable(FontListFontFamilyTypefaceAdapter.kt:1)
at androidx.compose.ui.text.font.FontListFontFamilyTypefaceAdapter.resolve(FontListFontFamilyTypefaceAdapter.kt:133)
at androidx.compose.ui.text.font.FontFamilyResolverImpl$resolve$result$1.invoke(FontFamilyResolver.kt:93)
at androidx.compose.ui.text.font.FontFamilyResolverImpl$resolve$result$1.invoke(FontFamilyResolver.kt:92)
at androidx.compose.ui.text.font.TypefaceRequestCache.runCached(FontFamilyResolver.kt:192)
... 131 more
Guys, do you know is it possible to share resources between
composeApp
andserver
? I can't do it because it says myserver
module should be marked as multiplatform module (becauseresources
module, that I apply toserver
module` should be also marked as multiplatform) - https://kotlinlang.slack.com/archives/C3PQML5NU/p1716676813612929
How is this related to the issue?
same issue here using kotlin = "2.0.0" compose = "1.6.20-dev1646"
whenever I try to create a composeResources directory I only get suggested this which is the old impl
@sereden you forgot about the src dir: move resources/commonMain
-> resources/src/commonMain
The official statement says:
Starting with 1.6.10, you can place resources in any module or source set, as long as you are using Kotlin 2.0.0 or newer, and Gradle 7.6 or newer.
However, when the resources are placed in another module then composeApp (I don't know whether it name or application plugin dependent) they are not generated
Affected platforms
To Reproduce Steps to reproduce the behavior:
Expected behavior The resources could be imported from another module
Screenshots
Demo KotlinProject 2.zip