mirzemehdi / KMPAuth

Kotlin Multiplatform Authentication Library targetting android and iOS
https://mirzemehdi.com/KMPAuth/
Apache License 2.0
231 stars 19 forks source link

No static method koinApplication #29

Closed s-septimiu closed 3 months ago

s-septimiu commented 5 months ago

Hello @mirzemehdi, I'm building a KMP mobile app project and I'm trying to integrate your auth library. I'm using kotlin 2.0.0 and I've followed instructions but I'm having the following crash when trying to create a GoogleAuthProvider.

java.lang.NoSuchMethodError: No static method koinApplication(Lkotlin/jvm/functions/Function1;)Lorg/koin/core/KoinApplication; in class Lorg/koin/dsl/KoinApplicationKt; or its super classes (declaration of 'org.koin.dsl.KoinApplicationKt' appears in /data/app/ro.car_time_app-5HcVP8-TVa1eM0HDKTnoZw==/base.apk:classes17.dex)
                                                                                                        at com.mmk.kmpauth.core.di.LibDependencyInitializer.initialize(LibDependencyInitializer.kt:29)
                                                                                                        at com.mmk.kmpauth.core.di.LibDependencyInitializer.initialize(LibDependencyInitializer.kt:20)
                                                                                                        at com.mmk.kmpauth.google.GoogleAuthProvider$GoogleAuthProviderImpl.create(GoogleAuthProvider.kt:48)
                                                                                                        at com.mmk.kmpauth.google.GoogleAuthProvider$Companion.create(GoogleAuthProvider.kt:23)
                                                                                                        at AppKt$App$1$1.invokeSuspend(App.kt:130)
                                                                                                        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
                                                                                                        at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
                                                                                                        at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
                                                                                                        at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:789)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                                                        at android.os.Looper.loop(Looper.java:164)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:6944)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Do you know why I'm having such a crash?

mirzemehdi commented 5 months ago

@s-septimiu which koin version you are using. Please try latest koin version 3.5.6 in your project and see if problem is solved

s-septimiu commented 5 months ago

@mirzemehdi I having the followings:

koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin" } koin-androidx-compose = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koinCompose" } koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" } koin-compose = { module = "io.insert-koin:koin-compose", version.ref = "koinComposeMultiplatform" }

koin = "3.6.0-Beta4" koinCompose = "3.6.0-Beta4" koinComposeMultiplatform = "3.6.0-wasm-alpha2"

So I think I'm using something newer than 3.5.6...

mirzemehdi commented 5 months ago

@s-septimiu yes, looks like koin versions are not compatible, I am using last stable version currently (3.5.6). I believe if you can use that version too it should solve your problem

s-septimiu commented 5 months ago

@mirzemehdi I've had the time to update the koin library entries and indeed, with 3.5.6 and 1.1.5 (koin-compose) it's working without problem.

Maybe would be a good idea to add some compatibility versions with koin if it's that tightly coupled in order to avoid people giving up on this library because of this error 😄

Thanks for the help!

mirzemehdi commented 5 months ago

as soon as koin version 3.6.0 is stable, I'll update here. If it takes longer than I expected, I'll include with beta version :)

mirzemehdi commented 3 months ago

@s-septimiu now latest version of kmpauth (2.1.0-alpha01) supports latest version of koin. this problem should be solved now.

used koin version: 4.0.0-RC1

https://github.com/mirzemehdi/KMPAuth/releases/tag/v2.1.0-alpha01

mirzemehdi commented 3 months ago

Closing this issue due to inactivity. If this is still an issue or need a help, please feel free to reopen the issue and provide additional context or updates. Thank you.