gpt4 book ai didi

android - java.lang.NoSuchFieldError : No field Companion of type Landroidx/compose/foundation/layout/BoxScope$Companion;

转载 作者:行者123 更新时间:2023-12-03 18:33:24 25 4
gpt4 key购买 nike

我第一次使用 Jetpack Compose,但出现此错误。我还没有弄清楚问题到底出在哪里,但我正在使用单 Activity 架构。如果需要更多信息,请告诉我。
根据错误,问题似乎来自脚手架。

                val scaffoldState = rememberScaffoldState()

Scaffold(
scaffoldState = scaffoldState,
snackbarHost = {
SnackbarHost(hostState = it)
}
) {
java.lang.NoSuchFieldError: No field Companion of type Landroidx/compose/foundation/layout/BoxScope$Companion; in class Landroidx/compose/foundation/layout/BoxScope; or its superclasses (declaration of 'androidx.compose.foundation.layout.BoxScope' appears in /data/app/com.octagon_technologies.scafe-0B8-dDpbnRqa6fydxFPekw==/base.apk)
at androidx.compose.material.SurfaceKt$Surface$1.invoke(Surface.kt:149)
at androidx.compose.material.SurfaceKt$Surface$1.invoke(Surface.kt:105)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:193)
at androidx.compose.material.SurfaceKt.Surface-F-jzlyU(Surface.kt:102)
at androidx.compose.material.ScaffoldKt$Scaffold$child$1.invoke(Scaffold.kt:168)
at androidx.compose.material.ScaffoldKt$Scaffold$child$1.invoke(Scaffold.kt:167)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:118)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.material.ScaffoldKt.Scaffold-J67Y1T8(Scaffold.kt:197)
at com.octagon_technologies.scafe.presentation.MainActivity$onCreate$1$1.invoke(MainActivity.kt:54)
at com.octagon_technologies.scafe.presentation.MainActivity$onCreate$1$1.invoke(MainActivity.kt:47)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:193)
at androidx.compose.material.TextKt.ProvideTextStyle(Text.kt:246)
at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:78)
at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:77)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:193)
at androidx.compose.material.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:69)
at com.octagon_technologies.scafe.presentation.ui.theme.ThemeKt.ScafeTheme(Theme.kt:46)
at com.octagon_technologies.scafe.presentation.MainActivity$onCreate$1.invoke(MainActivity.kt:47)
at com.octagon_technologies.scafe.presentation.MainActivity$onCreate$1.invoke(MainActivity.kt:46)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:346)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:202)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:201)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)

最佳答案

我有同样的错误并通过更新撰写版本解决了它。 Android Studio生成的新项目模板自带compose版本1.0.0-beta01打开 build.gradle 文件并更新

compose_version = '1.0.0-beta05'
或更新,如果你愿意。

关于android - java.lang.NoSuchFieldError : No field Companion of type Landroidx/compose/foundation/layout/BoxScope$Companion;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67073647/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com