koin: Does not support Kotlin 1.6.0
Describe the bug
Latest koin version produces NoSuchMethodErrors at runtime when using kotlin 1.6.0-RC
To Reproduce Steps to reproduce the behavior:
- Add latest stable koin dependency
- Use kotlin 1.6.0-RC.
- App crashes on startup in 100% cases
Expected behavior The app is able to run without crashing.
Koin project used and used version (please complete the following information):
[e.g]: koin version 3.1.2, kotlin 1.6.0-RC
The surest way to get a runtime error is to call a deleted method toDouble() of kotlin.duration that was removed in 1.6.0 by using
startKoin {
androidContext(applicationContext)
androidLogger() //This one is causing the crash
modules(/* blah */)
}
Stacktrace:
java.lang.NoSuchMethodError: No static method toDouble-impl(JLjava/util/concurrent/TimeUnit;)D in class Lkotlin/time/Duration; or its super classes (declaration of 'kotlin.time.Duration' appears in /data/app/~~RAEJCWfLUZeoA5jJfJMmtA==/com.nek.test.debug-jvqFgZyETecELyVm71SR5A==/base.apk!classes16.dex)
at org.koin.core.time.MeasureKt.measureDuration(Measure.kt:32)
at org.koin.core.KoinApplication.modules(KoinApplication.kt:59)
at org.koin.core.KoinApplication.modules(KoinApplication.kt:50)
at com.nek.test.TestApplication$onCreate$1.invoke(TestApplication.kt:30)
at com.nek.test.TestApplication$onCreate$1.invoke(TestApplication.kt:27)
at org.koin.core.context.GlobalContext.startKoin(GlobalContext.kt:64)
at org.koin.core.context.DefaultContextExtKt.startKoin(DefaultContextExt.kt:31)
at com.nek.test.TestApplication.onCreate(TestApplication.kt:27)
//bunch of junk
Lesson: do not use experimental APIs
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 78
- Comments: 27 (3 by maintainers)
Commits related to this issue
- Dependency Updates * Updating Kotlin to 1.6.10 required updating some Compose dependencies to the next RC versions (which support a matching version of Kotlin) * Add support to use `ksp` for Moshi co... — committed to BottleRocketStudios/Android-ArchitectureDemo by jaredstockton 2 years ago
- Dependency Updates (#32) * Updating Kotlin to 1.6.10 required updating some Compose dependencies to the next RC versions (which support a matching version of Kotlin) * Add support to use `ksp` for M... — committed to BottleRocketStudios/Android-ArchitectureDemo by jaredstockton 2 years ago
Set Koin logger to level Error, as a workaround for the time being
Hi. Any update on this issue? Kotlin 1.6.0 has been released to production and this crash happens, making it impossible to upgrade Kotlin… Thanks.
Koin 3.2.0 will bring Kotlin 1.6
Koin 3.2 is updated for Kotlin 1.6.10 👍
Yes, exactly the same happened when Kotlin 1.5 was released: #1076
Durationis nice, but we really should think twice before using experimental API in a public library.Workaround for Ktor:
That worked. Thanks.
For those creating their own
Logger(for me I created a custom logger wrappingTimber) and not usingAndroidLoggermake sure to include this as the argumentLevelto the baseLoggerclass, or anything that avoidsLevel.INFOandLevel.DEBUG.Great news, but note that anyone who still targets SDK 29 won’t be able to update to Koin 3.2.0: Koin 3.1.3+ updates its
androidx.activity:activity-ktxdependency to 1.3.1, which requires a minCompileSdk of 30.Play Store required all app updates to target SDK 30 back in November 2021, but if you’re not using it to publish apps, you’re stuck with this workaround (suggested earlier in this thread):
my case, also get rid of manually set logger for now
const val KOIN = “3.1.4” const val KOTLIN = “1.6.0” Crash Log: Caused by: o6.c: Could not create instance for [Singleton:‘v3.c’] in Release Build
I remember another bug related to this
androidLoggerbefore 🧐