You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Jetpack Compose Live Edit模式下重组错误求助

Android Compose Live Edit 修改Text文本时的重组错误

在Android模拟器中使用Live Edit修改Compose的Text组件文本值时触发重组错误,已尝试重建项目但问题未解决。

代码示例

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            Text(text = "hi99")

        }
    }
}

错误日志

Error was captured in composition while live edit was enabled.
java.lang.IllegalStateException: Cannot find 'Text-nZBYWUE(Ljava/lang/String;Landroidx/compose/ui/Modifier;JJLandroidx/compose/ui/text/font/FontStyle;Landroidx/compose/ui/text/font/FontWeight;Landroidx/compose/ui/text/font/FontFamily;JLandroidx/compose/ui/text/style/TextDecoration;Landroidx/compose/ui/text/style/TextAlign;JIZIILkotlin/jvm/functions/Function1;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/runtime/Composer;III)V' in androidx/compose/material3/TextKt
Found:
    'class androidx.compose.material3.TextKt.ProvideTextStyle[class androidx.compose.ui.text.TextStyle, interface kotlin.jvm.functions.Function2, interface androidx.compose.runtime.Composer, int]void
    'class androidx.compose.material3.TextKt.Text--4IGK_g[class androidx.compose.ui.text.AnnotatedString, interface androidx.compose.ui.Modifier, long, long, class androidx.compose.ui.text.font.FontStyle, class androidx.compose.ui.text.font.FontWeight, class androidx.compose.ui.text.font.FontFamily, long, class androidx.compose.ui.text.style.TextDecoration, class androidx.compose.ui.text.style.TextAlign, long, int, boolean, int, interface java.util.Map, interface kotlin.jvm.functions.Function1, class androidx.compose.ui.text.TextStyle, interface androidx.compose.runtime.Composer, int, int, int]void
    'class androidx.compose.material3.TextKt.Text--4IGK_g[class java.lang.String, interface androidx.compose.ui.Modifier, long, long, class androidx.compose.ui.text.font.FontStyle, class androidx.compose.ui.text.font.FontWeight, class androidx.compose.ui.text.font.FontFamily, long, class androidx.compose.ui.text.style.TextDecoration, class androidx.compose.ui.text.style.TextAlign, long, int, boolean, int, int, interface kotlin.jvm.functions.Function1, class androidx.compose.ui.text.TextStyle, interface androidx.compose.runtime.Composer, int, int, int]void
    'class androidx.compose.material3.TextKt.Text-IbK3jfQ[class androidx.compose.ui.text.AnnotatedString, interface androidx.compose.ui.Modifier, long, long, class androidx.compose.ui.text.font.FontStyle, class androidx.compose.ui.text.font.FontWeight, class androidx.compose.ui.text.font.FontFamily, long, class androidx.compose.ui.text.style.TextDecoration, class androidx.compose.ui.text.style.TextAlign, long, int, boolean, int, int, interface java.util.Map, interface kotlin.jvm.functions.Function1, class androidx.compose.ui.text.TextStyle, interface androidx.compose.runtime.Composer, int, int, int]void
    'class androidx.compose.material3.TextKt.Text-fLXpl1I[class java.lang.String, interface androidx.compose.ui.Modifier, long, long, class androidx.compose.ui.text.font.FontStyle, class androidx.compose.ui.text.font.FontWeight, class androidx.compose.ui.text.font.FontFamily, long, class androidx.compose.ui.text.style.TextDecoration, class androidx.compose.ui.text.style.TextAlign, long, int, boolean, int, interface kotlin.jvm.functions.Function1, class androidx.compose.ui.text.TextStyle, interface androidx.compose.runtime.Composer, int, int, int]void
    'class androidx.compose.material3.TextKt.getLocalTextStyle[]class androidx.compose.runtime.ProvidableCompositionLocal
    'class java.lang.Object.identityHashCode[class java.lang.Object]int
    'class java.lang.Object.identityHashCodeNative[class java.lang.Object]int
    'class java.lang.Object.internalClone[]class java.lang.Object
    'class java.lang.Object.clone[]class java.lang.Object
    'class java.lang.Object.equals[class java.lang.Object]boolean
    .....

解决方法

  • 禁用Live Edit重试:暂时关闭Live Edit功能,直接重新编译运行项目,修改文本后再尝试开启Live Edit。
  • 清除IDE缓存:点击Android Studio菜单栏的 File -> Invalidate Caches...,勾选 Invalidate and Restart 选项重启IDE。
  • 统一Compose依赖版本:检查项目中所有Compose相关依赖(material3、ui、runtime等)的版本是否完全一致,版本不匹配会导致方法签名不兼容。
  • 升级Android Studio:如果使用旧版本IDE,升级到最新稳定版,Live Edit功能的兼容性问题在新版本中可能已修复。
  • 清理构建目录:手动删除项目根目录下的 build 文件夹和 app/build 文件夹,重新执行构建。

内容的提问来源于stack exchange,提问作者Mohammed Arfath

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 07:35:31