koin: [Crash] Koin Logger Measure and Kotlin EAP 1.4-M3
Describe the bug
This is just a heads up on Koin and Kotlin EAP 1.4-M3.
After upgrading to Kotlin EAP 1.4-M3 (from previous Kotlin EAP 1.4-M2) when launching the app a NoSuchMethodException exception is thrown due to the elapseNow() experimental method.
Full exception below:
java.lang.NoSuchMethodError: No virtual method elapsedNow()D in class Lkotlin/time/TimeMark; or its super classes (declaration of 'kotlin.time.TimeMark' appears in /data/app/io.petros.movies-u-dzv9wkMPKfx19uLVQWyg==/base.apk)
at org.koin.core.time.MeasureKt.measureDuration(Measure.kt:36)
at org.koin.core.KoinApplication.modules(KoinApplication.kt:60)
at io.petros.movies.app.App$initKoin$1.invoke(App.kt:45)
at io.petros.movies.app.App$initKoin$1.invoke(App.kt:23)
at org.koin.core.context.ContextFunctionsKt.startKoin(ContextFunctions.kt:39)
at org.koin.core.context.ContextFunctionsKt.startKoin$default(ContextFunctions.kt:35)
at io.petros.movies.app.App.initKoin(App.kt:42)
at io.petros.movies.app.App.onCreate(App.kt:34)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1189)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
This is due to the fact that my app is using androidLogger(), which default to a Koin log level of Level.INFO and as such when modules are build the duration is measured, which crashes the app. To overcome this I disabled logging for now, but it will be good if that get fixed so that I can enable it again.
To Reproduce Steps to reproduce the behavior:
- Use
Kotlin EAP 1.4-M3as a dependency in your app (or project) - During
Koininit start with default logging enabled (Level.INFO) - Launch your app (or project)
- See error
Expected behavior I except the app to not crash.
Koin project used and used version (please complete the following information): org.jetbrains.kotlin:kotlin-stdlib:1.4-M3 org.koin:koin-core:2.1.6 org.koin:koin-android:2.1.6 org.koin:koin-androidx-viewmodel:2.1.6
Additional moduleDefinition No additional moduleDefinition.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 46
- Comments: 26 (4 by maintainers)
Commits related to this issue
- [movies] update: Update kotlin to latest eap 1.4-M3 version As part of this update the below changes occurred: 1) 'initKoin' and 'androidLogger()' was updated to 'Level.ERROR' from the default 'Level... — committed to ParaskP7/sample-code-movies by ParaskP7 4 years ago
- Temporarily supress koin logs to avoid kotlin compatibility crash See issue: https://github.com/InsertKoinIO/koin/issues/847 Triggered by commit: f918c71d82f970c6a48281a9cc1f2e23996ef9a0 — committed to AniTrend/retrofit-graphql by wax911 4 years ago
- Demo restored Not finished and crashes because of an ongoing Koin bug https://github.com/InsertKoinIO/koin/issues/847 — committed to shkschneider/android_Skeleton by deleted user 4 years ago
- Demo restored (1/2) Crashes with Koin because of an ongoing bug: https://github.com/InsertKoinIO/koin/issues/847 — committed to shkschneider/android_Skeleton by deleted user 4 years ago
- Updated dependencies - Kotlin 1.4.0 (from 1.3.72): https://blog.jetbrains.com/kotlin/2020/08/kotlin-1-4-released-with-a-focus-on-quality-and-performance/ `stdlib` dependency doesn't need to be expli... — committed to oxygen-updater/oxygen-updater by adhirajsinghchauhan 4 years ago
- Updated Koin library dependency to beta version '2.2.0-beta-1' due to logging crash. Could be changed to stable 2.1.7 when it released. Reference: https://github.com/InsertKoinIO/koin/issues/847 — committed to Pulimet/SamplesApp by Pulimet 4 years ago
- Updated dependencies - Kotlin 1.4.10 (from 1.4.0): https://blog.jetbrains.com/kotlin/2020/08/kotlin-1-4-released-with-a-focus-on-quality-and-performance/ Important bugfixes and perf improvements - K... — committed to oxygen-updater/oxygen-updater by adhirajsinghchauhan 4 years ago
Would be nice to release 2.1.7 with just this fixed. This is the only way that’s stopping my team from updating to Kotlin 1.4. (Sure, there are workarounds, but…)
I’m facing the same issue with
1.4.0-rctoo. ❗ Temporary workaround: Migrate fromandroidLogger()toandroidLogger(Level.ERROR)Kotlin 1.4 + 2.2.0-alpha-1 works well.
Kotlin 1.4 becomes stable, waiting new release 🌸
same issue kotlin 1.5.0 + koin 3.0.1
androidLogger(Level.INFO) crashed
Same problem here, updating to stable Kotlin 1.4 bricks loading the modules because the still experimental time API seems to have changed something under the hood, I’m using a modified copy of
modulesnow that doesn’t use the time API to fix this.@arnaudgiuliani Would have been nice to know upfront that Koin is using unstable experimental API under the hood, and in such a core code path even - silently opting in to the
ExperimentalTimeannotation seems like a questionable choice hereI got this crash after updating to stable Kotlin 1.4.0 while everything worked fine before on 1.3.72 Kotlin and 2.1.6 Koin.
Release Candidate version
2.2.0-rc-3has this issue fixedFWIW the encapsulated functionality of
modules()is public, so you’d also be able to work around this by inlining the work of that method in your own setup. This way, there is no need to lose all info-level logging going forward.Kotlin 1.4.10 + Koin 2.2.1 - this works for me.
Can confirm - this works for me.
I am facing the same issue with koinVersion = ‘2.1.6’.
This workaround is working btw.