Kotlin / kotlinx-datetime

KotlinX multiplatform date/time library
Apache License 2.0
2.39k stars 99 forks source link

Is KMM still possible for apps that supports SDK 21? #407

Closed ArcherEmiya05 closed 2 months ago

ArcherEmiya05 commented 2 months ago

I am in migration of Java 8+ APIs Desugar to KotlinX DateTime for an app that supports SDK 21 to 34, upon reading the README.md with the statement below I was confuse.

If you target Android devices running below API 26, you need to use Android Gradle plugin 4.0 or newer and enable core library desugaring.

Isn't Java 8+ APIs Desugar depends on JVM hence cannot be use for KMM project?

dkhalanskyjb commented 2 months ago

If you use kotlinx-datetime in a KMM project and enable core library desugaring, it will only affect the JVM target. The other targets will use their own implementations in any case, without delegating to the JVM.

ArcherEmiya05 commented 2 months ago

What if a feature module that supposed to be a platform agnostic depends on KotlinX DateTime? Does it still need to include desugar library or only on the androidApp module? I am planning to adapt this module to be use as shared/common module for a KMM project.

dkhalanskyjb commented 2 months ago

Only the application must enable the desugaring. Intermediate modules shouldn't do that.