InsertKoinIO / koin

Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform
https://insert-koin.io
Apache License 2.0
8.95k stars 712 forks source link

NoSuchMethodError: No virtual method setupLogger #993

Closed developer-- closed 3 years ago

developer-- commented 3 years ago

When I run the project it crashes with NoSuchMethodError exception:

 Process: com.spms.app, PID: 24997
    java.lang.NoSuchMethodError: No virtual method setupLogger(Lorg/koin/core/logger/Logger;)V in class Lorg/koin/core/Koin; or its super classes (declaration of 'org.koin.core.Koin' appears in /data/data/com.example.package/code_cache/.overlay/base.apk/classes32.dex)
        at org.koin.android.ext.koin.KoinExtKt.androidLogger(KoinExt.kt:43)
        at com.example.package.MyApplication$onCreate$1.invoke(MyApplication.kt:33)

Koin versions:

val koin_version_for_KMM = "3.0.0-alpha-4"
val koin_version_for_android = "2.2.2"
val kotlin_version = '1.4.21

val coroutinesVersion = "1.4.2"
val sqlDelight = "1.4.4"
val ktorVersion = "1.5.0"
val serializationVersion = "1.0.0-RC"

here is how I'm starting the koin inside Application.

 initKoin {
    androidLogger(Level.NONE)
    androidContext(this@MyApplication)
    modules(listOf(
       exampleModules1,
       ...
       exampleModules2
 ))

I have also tried:

initKoin {
  androidLogger(Level.NONE)
  androidContext(this@MyApplication)
  koin.loadModules(listOf(
      exampleModules1,
      ...
      exampleModules2
   ))
  koin.createRootScope()
}

and here is my initKoin method inside multiplatform shared module

fun initKoin(appDeclaration: KoinAppDeclaration = {}) = startKoin {
  appDeclaration()
  modules(
     exampleSharedModules1,
               ...
     exampleSharedModules2
  )
}
developer-- commented 3 years ago

Just found the issue, I changed koin_version_for_android = 2.2.2 with3.0.0-alpha-4 and now error has gone. Strange thing is that, before some updates it was working with 2.2.0 version