52

I have recently updated the version of Kotlin to 1.4.0-rc.

Since then Koin is returning the run time error below:

java.lang.NoSuchMethodError: No virtual method elapsedNow()D in class Lkotlin/time/TimeMark

Aydinozkan
  • 2,508
  • 2
  • 21
  • 26

2 Answers2

48

Apparently this issue is due to the usage of androidLogger() together with Koin. There is only a workaround for now, which is migrating from androidLogger() to androidLogger(Level.ERROR)

There is already an issue created for this purpose:

https://github.com/InsertKoinIO/koin/issues/847

Aydinozkan
  • 2,508
  • 2
  • 21
  • 26
  • 5
    As mentioned by Martin Bove in another answer (https://stackoverflow.com/a/63734210/1139514), the issue has been fixed in Koin version `2.2.0-alpha-1`. – Marco7757 Sep 08 '20 at 06:38
  • 3
    I had this issue with Koin 2.2.2, but it got fixed in 2.2.3 (which is in a final state, not alpha nor beta). Beware that Koin changed its vendor name from ```org.koin``` to ```io.insert-koin```. – xarlymg89 Aug 19 '21 at 14:24
  • Same here using 2.2.2 and had to upgrade to 2.2.3 for app to not crash on this – JPM Oct 11 '21 at 03:02
45

With the latest alpha version the problem is solved in my case.

// latest unstable
koin_version = '2.2.0-alpha-1'
implementation "org.koin:koin-androidx-scope:$koin_version"
implementation "org.koin:koin-androidx-viewmodel:$koin_version"
implementation "org.koin:koin-androidx-fragment:$koin_version"

Go to the main documentation for more details: Koin latest version

Another way to avoid the problem is how @Aydinozkan says by setting the logger level to error or none.

startKoin {
        androidLogger(Level.NONE)          
    }
AliSh
  • 10,085
  • 5
  • 44
  • 76
Martin Bove
  • 645
  • 6
  • 11