MohamedRejeb / Calf

Calf is a library that allows you to easily create adaptive UIs and access platform specific APIs with Compose Multiplatform (Adaptive UI, File Picker, WebView, Permissions...).
https://mohamedrejeb.github.io/Calf/
Apache License 2.0
933 stars 42 forks source link

App Crashes while instantiating rememberAdaptiveTimePickerState() #169

Open saifi369 opened 2 months ago

saifi369 commented 2 months ago

Hi, My app is crashing on Android and iOS while instantiating adaptive time picker state.

val state = rememberAdaptiveTimePickerState(
                    initialHour = 12,
                    initialMinute = 10,
                    is24Hour = true
                )

I'm getting this exception:

java.lang.InstantiationError: androidx.compose.material3.TimePickerState
                                                                                                        at com.mohamedrejeb.calf.ui.timepicker.AdaptiveTimePickerState.<init>(AdaptiveTimePickerState.material.kt:35)
                                                                                                        at com.mohamedrejeb.calf.ui.timepicker.AdaptiveTimePickerStateKt.rememberAdaptiveTimePickerState$lambda$1$lambda$0(AdaptiveTimePickerState.kt:17)
                                                                                                        at com.mohamedrejeb.calf.ui.timepicker.AdaptiveTimePickerStateKt.$r8$lambda$7dEtWSPSD9VEsYQkVJY_7cp3ftU(Unknown Source:0)
                                                                                                        at com.mohamedrejeb.calf.ui.timepicker.AdaptiveTimePickerStateKt$$ExternalSyntheticLambda0.invoke(Unknown Source:6)
                                                                                                        at androidx.compose.runtime.saveable.RememberSaveableKt.rememberSaveable(RememberSaveable.kt:89)
                                                                                                        at com.mohamedrejeb.calf.ui.timepicker.AdaptiveTimePickerStateKt.rememberAdaptiveTimePickerState(AdaptiveTimePickerState.kt:14)

PS: I've tested the AlertDialog and that works fine.

MohamedRejeb commented 2 months ago

Thanks for reporting this issue. Can you share the versions you are using.

saifi369 commented 2 months ago

I'm using these versions.

calf = "0.5.5"
compose = "1.6.11"
kotlin = "2.0.10"
MohamedRejeb commented 2 months ago

I will check it.

MohamedRejeb commented 2 months ago

Couldn't reproduce it. Can you try the app sample and let me know if it happens for you there as well?

saifi369 commented 2 months ago

I've tried on a blank project and it works without any issue but crashes on my main project. I'm attaching the project link if you want to investigate further. You can try the main branch, application will crash during the onboarding screens. https://github.com/saifi369/KMP-ExpenseTracker

App crashes on this line : https://github.com/saifi369/KMP-ExpenseTracker/blob/c8042091c424a9455f06887dab1187c4eed951ed/composeApp/src/commonMain/kotlin/presentation/screen/accountsetup/AccountSetupScreen.kt#L157

MohamedRejeb commented 2 months ago

I will check it.

saifi369 commented 2 months ago

@MohamedRejeb I've resolved the issue after changing the compose-plugin from 1.7.0-alpha0 to 1.6.11. My bad 😆 Please feel free to close this.

saifi369 commented 1 month ago

Hi @MohamedRejeb

After downgrading to compose 1.6.11, app works fine on Android but I'm getting this exception for iOS.

> Task :composeApp:compileKotlinIosSimulatorArm64
Failed to load native library:libjansi.jnilib. The native library file at /Users/saifi369/.gradle/native/jansi/1.18/osx/libjansi.jnilib is not executable, make sure that the directory is mounted on a partition without the noexec flag, or set the jansi.tmpdir system property to point to a proper location.  osinfo: Mac/arm64
java.lang.UnsatisfiedLinkError: /Users/saifi369/.gradle/native/jansi/1.18/osx/libjansi.jnilib: dlopen(/Users/saifi369/.gradle/native/jansi/1.18/osx/libjansi.jnilib, 0x0001): tried: '/Users/saifi369/.gradle/native/jansi/1.18/osx/libjansi.jnilib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/saifi369/.gradle/native/jansi/1.18/osx/libjansi.jnilib' (no such file), '/Users/saifi369/.gradle/native/jansi/1.18/osx/libjansi.jnilib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))

I also tried running the project from XCode but that fails as well.