https://kotlinlang.org logo
Title
n

Nikita Khlebushkin

07/16/2021, 6:12 PM
Hello! I am having some strange bug:
java.lang.NoSuchFieldError: No field MIN of type Lj$/time/Instant; in class Lj$/time/Instant; or its superclasses (declaration of 'j$.time.Instant' appears in /data/app/my.app-Rumayx4kmF4yH-665uzCBw==/base.apk!classes2.dex)
        at kotlinx.datetime.Instant.<clinit>(Instant.kt:96)
        at kotlinx.datetime.Clock$System.now(Clock.kt:17)
The line where it happens:
val fetchStartEpoch = clock.now().toEpochMilliseconds()
I tried with datetime 0.1.1 and 0.2.1, same result. Another interesting detail is that it only happened after I added
compileOptions {
        isCoreLibraryDesugaringEnabled = true
    }
I had to add it after the library started to crash on Android 26. Any clues how I can deal with it?
The problem solved: I had this logic in a framework which I plugged into an Android project. The compileOptions were added to the Android project instead of the framework, and when I moved that line out to the framework, everything began to work again.
The problem seems to be still there but in a bit different way: Given: there is a native application and a KMM library that uses
datetime
as a dependency. The app crashes on API 24 on the library execution step with the error in the OP. Adding
isCoreLibraryDesugaringEnabled = true
in
android
block of the library doesn't help, adding this line into native app crashes the app literally on each platform (not just 24). Is there something I am doing wrongly?