Koin: Koin MonoClock class not found with Kotlin 1.3.70

Created on 3 Mar 2020  路  5Comments  路  Source: InsertKoinIO/koin

Describe the bug
An app with Koin 2.1.0 or 2.1.1 will crash at runtime with:

2020-03-03 11:48:45.259 18449-18449/com.example.base E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.base, PID: 18449
    java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/time/MonoClock;
        at org.koin.core.time.MeasureKt.measureDuration(Measure.kt:31)
        at org.koin.core.KoinApplication.modules(KoinApplication.kt:60)
        at com.example.base.App$startDependencyInjection$1.invoke(App.kt:23)
        at com.example.base.App$startDependencyInjection$1.invoke(App.kt:11)
        at org.koin.core.context.ContextFunctionsKt.startKoin(ContextFunctions.kt:39)
        at org.koin.core.context.ContextFunctionsKt.startKoin$default(ContextFunctions.kt:35)
        at com.example.base.App.startDependencyInjection(App.kt:20)
        at com.example.base.App.onCreate(App.kt:15)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6601)
        at android.app.ActivityThread.access$1300(ActivityThread.java:226)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1886)
        at android.os.Handler.dispatchMessage(Ha

after upgrading to Kotlin 1.3.70.

To Reproduce
Steps to reproduce the behavior:

  1. Create a simple Koin app with at least one module.
  2. Upgrade Kotlin to 1.3.70
  3. Run App.
  4. See error

Expected behavior
Should not crash.

Koin project used and used version (please complete the following information):
koin-android version 2.1.0 or 2.1.1

Most helpful comment

Compiling Koin using 1.3.70 reveals a good number of update suggestions:

w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/registry/InstanceRegistry.kt: (128, 52): Unchecked cast: Any? to S
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (18, 20): 'typealias MonoClock = TimeSource.Monotonic' is deprecated. Use TimeSource.Monotonic instead.
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (29, 2): 'UseExperimental' is deprecated. Please use OptIn instead.
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (29, 2): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (31, 17): 'typealias MonoClock = TimeSource.Monotonic' is deprecated. Use TimeSource.Monotonic instead.
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (37, 2): 'UseExperimental' is deprecated. Please use OptIn instead.
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (37, 2): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (46, 2): 'UseExperimental' is deprecated. Please use OptIn instead.
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (46, 2): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (48, 17): 'typealias MonoClock = TimeSource.Monotonic' is deprecated. Use TimeSource.Monotonic instead.

All 5 comments

Poking around, looks like the Experimental API was changed. https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib/src/kotlin/time

Compiling Koin using 1.3.70 reveals a good number of update suggestions:

w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/registry/InstanceRegistry.kt: (128, 52): Unchecked cast: Any? to S
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (18, 20): 'typealias MonoClock = TimeSource.Monotonic' is deprecated. Use TimeSource.Monotonic instead.
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (29, 2): 'UseExperimental' is deprecated. Please use OptIn instead.
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (29, 2): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (31, 17): 'typealias MonoClock = TimeSource.Monotonic' is deprecated. Use TimeSource.Monotonic instead.
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (37, 2): 'UseExperimental' is deprecated. Please use OptIn instead.
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (37, 2): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (46, 2): 'UseExperimental' is deprecated. Please use OptIn instead.
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (46, 2): This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'
w: /Users/nealsanche/github/koin/koin-projects/koin-core/src/main/kotlin/org/koin/core/time/Measure.kt: (48, 17): 'typealias MonoClock = TimeSource.Monotonic' is deprecated. Use TimeSource.Monotonic instead.

accepted PR.

Wait for 2.1.2 soon 馃憤

Works great, i think this can be closed

thanks :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LukasAnda picture LukasAnda  路  3Comments

AHarazim picture AHarazim  路  3Comments

iRYO400 picture iRYO400  路  3Comments

CristianMG picture CristianMG  路  3Comments

caleb-allen picture caleb-allen  路  4Comments