touchlab / KaMPKit

KaMP Kit by Touchlab. A collection of code & tools designed to get your mobile team started quickly w/Kotlin Multiplatform
https://touchlab.co/
Apache License 2.0
2.2k stars 199 forks source link

Crash on api 21 #156

Closed samhill303 closed 3 years ago

samhill303 commented 3 years ago

App wont open due to the following crash on Pixel 3 API 21 emulator due to the following crash. Possible kotlinx datetime doesn't support that low?

java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/Instant;
        at kotlinx.datetime.Instant.<clinit>(Instant.kt:78)
        at kotlinx.datetime.Clock$System.now(Clock.kt:17)
        at co.touchlab.kampkit.models.BreedModel.getBreedsFromNetwork(BreedModel.kt:46)
        at co.touchlab.kampkit.android.BreedViewModel$getBreedsFromNetwork$1.invokeSuspend(BreedViewModel.kt:32)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:333)
        at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.startCoroutineImpl(Builders.common.kt:180)
        at kotlinx.coroutines.BuildersKt.startCoroutineImpl(Unknown Source)
        at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:145)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:54)
        at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
        at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source)
        at co.touchlab.kampkit.android.BreedViewModel.getBreedsFromNetwork(BreedViewModel.kt:31)
        at co.touchlab.kampkit.android.MainActivity.onCreate(MainActivity.kt:42)
        at android.app.Activity.performCreate(Activity.java:5937)
kkalisz commented 3 years ago

I think that desugaring for java 8 language features needs to be enabled.

https://github.com/Kotlin/kotlinx-datetime/issues/54 https://developer.android.com/studio/write/java8-support#library-desugaring

russhwolf commented 3 years ago

Yeah that'll be it. Should have checked it when we merged the kotlinx-datetime stuff

brady-aiello commented 3 years ago

From the README:

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.