升级Flutter、intl及Sentry7.11后启动报错:找不到androidx.compose的Owner类
问题原因
Sentry 7.x版本默认启用了Jetpack Compose相关集成模块,但你的项目未引入Compose依赖,导致Sentry初始化时尝试加载androidx.compose.ui.node.Owner类触发ClassNotFoundException。
解决方案
禁用不必要的Compose集成(项目不使用Compose时):
在Flutter项目的Sentry初始化代码中添加配置关闭Compose集成:await SentryFlutter.init( (options) { options.dsn = '你的DSN地址'; // 关闭Compose集成 options.android.enableComposeIntegration = false; }, appRunner: () => runApp(MyApp()), );添加Compose依赖(项目需要使用Compose时):
在Android模块的build.gradle(模块级)中配置Compose相关内容:android { buildFeatures { compose true } composeOptions { kotlinCompilerExtensionVersion "1.5.3" // 版本需与项目Kotlin版本匹配 } } dependencies { implementation "androidx.compose.ui:ui:1.5.4" // 根据需求添加其他Compose依赖,如material、foundation等 }清理缓存重新构建:
执行以下命令清理缓存后重新运行项目:flutter clean rm -rf android/.gradle flutter pub get flutter run
内容的提问来源于stack exchange,提问作者ANewbieDeveloper
相关产品推荐
相关产品推荐

