'No default context on LocalContext.current
Using LocalContext.current results in app crash telling me:
java.lang.IllegalStateException: No default context
at androidx.glance.CompositionLocalsKt$LocalContext$1.invoke(CompositionLocals.kt:35)
at androidx.glance.CompositionLocalsKt$LocalContext$1.invoke(CompositionLocals.kt:35)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at androidx.compose.runtime.LazyValueHolder.getCurrent(ValueHolders.kt:29)
at androidx.compose.runtime.LazyValueHolder.getValue(ValueHolders.kt:31)
at androidx.compose.runtime.ComposerImpl.resolveCompositionLocal(Composer.kt:1776)
at androidx.compose.runtime.ComposerImpl.consume(Composer.kt:1746)
at com.bqubique.quran_randomayah.view.VerseCardKt.ButtonTile(VerseCard.kt:282)
at com.bqubique.quran_randomayah.view.ComposableSingletons$VerseCardKt$lambda-2$1.invoke(VerseCard.kt:79)
at com.bqubique.quran_randomayah.view.ComposableSingletons$VerseCardKt$lambda-2$1.invoke(VerseCard.kt:79)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at
...
Versions used:
compose_version = '1.0.5'
wear_compose_version = '1.0.0-alpha15'
I have tried calling LocalContext.current in any kind of @Composable, even in MainActivity.kt inside setContent{...}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
