https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
n

Nikola Milovic

05/31/2021, 11:49 AM
Hey guys anyone else having trouble with actual/expect and composables? They might not be related but I have in my commonMain some composables and I need some platform specific code
isSystemInDarkTheme()
. I declare it as
Copy code
@Composable
expect fun isSystemInDarkTheme() : Boolean
And I implement it on my desktop and my android Mains. But I keep gettting the error
java.lang.NoSuchMethodError: No static method isSystemInDarkTheme(Landroidx/compose/runtime/Composer;I)Z in class
If I try and just make the function be
fun isSys... () = true
then I get another expect/ actual error with unresolved reference for another function... Anyone had similar issues? I saw that there are issues with default parameters and suspend funcs with actual/expect but nothing similar to mine
a

Arkadii Ivanov

05/31/2021, 12:53 PM
Assuming you are using Compose for Desktop, there are examples of expect/actual Composable functions for scroll bars: https://github.com/JetBrains/compose-jb/blob/master/examples/todoapp/common/compose-ui/src/commonMain/kotlin/example/todo/common/ui/Scrollbars.kt
n

Nikola Milovic

05/31/2021, 2:37 PM
@Arkadii Ivanov Yep, using that as reference. I just double checked that I am using same setup and versions. I have the same actual/exact setup here it's the expect fun in the commonMain Implemented in the desktop and android main Heres the stack trace of crash: https://hastebin.com/tesilepiwu.apache
a

Arkadii Ivanov

05/31/2021, 2:48 PM
The only difference I see is the path:
com.nikolam.kmm_weather.ui
instead of
com/nikolam/kmm_weather/ui
, this still should work, but maybe it confuses somehow.
n

Nikola Milovic

06/02/2021, 6:48 AM
Seems to be a bug, I kept getting NoSuchMethodError and Unresolved references and without changing anything it started compiling the methods. On a side note @Arkadii Ivanov will you be updating the Todo example versions of the libraries like gradle plugin/ compose/ decompose and etc? I've had a lot of issues with versioning without breaking the project, it would be nicer to just follow the versions of the Todo example
a

Arkadii Ivanov

06/02/2021, 10:15 AM
@Nikola Milovic I'm trying to keep main libraries up to date. JB are updating Compose version in all examples. Other libraries are less important, but I will check later. At the moment it is not possible to update Kotlin and Compose to latest versions, due to recently broken binary compatibility in Compose and other bugs recently introduced. Waiting for today's
beta08
release.
22 Views