Reputation: 1027
I tried to update from kotlin 1.4 to 1.5 and was updating the deprecated methods. One of said methods was for the duration of second which is then converted to minutes.
durationInSeconds.seconds.inMinutes
Which I changed to:
Duration.seconds(durationInSeconds).inWholeMinutes.toDouble()
The problem is that this works fine on compile time but on runtime I get the following error:
java.lang.NoSuchMethodError: 'double kotlin.time.DurationKt.getSeconds(int)'
Is there a solution for said problem or should I for now stick with kotlin 1.4?
Upvotes: 0
Views: 1628
Reputation: 1941
Duration API changes in Kotlin 1.5 are experimental, and require explicit opt in. It is likely you could be missing this.
If you would like to opt in to this, Duration APIs' usage must be marked with
@kotlin.time.ExperimentalTime
or
@OptIn(kotlin.time.ExperimentalTime::class)
You can also have a look here for granular opt-in controls.
Upvotes: 2