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

Flutter Firebase安卓应用无法启动,Chrome端正常运行求助

Flutter安卓模拟器启动卡住问题

问题描述

  • 应用在Chrome浏览器端可正常启动,但在安卓模拟器(sdk gphone64 x86 64)中运行时卡住,控制台持续显示:Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
  • 已尝试清理模拟器缓存、重新创建build.gradle文件,查阅Stack Overflow相关问题后仍未找到解决方案

相关代码(main.dart)

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: const HomeScreen(),
      theme: lightMode,
    );
  }
}

控制台截图

控制台启动卡住截图

排查建议

  • Firebase初始化验证:在Firebase.initializeApp前后添加打印日志,确认是否卡在Firebase初始化步骤。同时检查google-services.json文件是否正确放置在安卓项目app目录下,配置信息与项目匹配。
  • 模拟器架构切换:x86架构模拟器可能存在兼容性问题,尝试创建ARM64架构的安卓模拟器重新测试。
  • 版本兼容性检查:核对pubspec.yaml中firebase_core等Firebase插件版本与当前Flutter稳定版是否兼容,必要时升级或降级插件版本。
  • 调整启动超时:在Android Studio的「Run/Debug Configurations」中,找到Flutter启动配置,在「Additional run args」中添加--timeout 300延长启动超时时间。
  • 简化启动页面:暂时将home: const HomeScreen()替换为home: Scaffold(body: Center(child: Text('测试'))),排除HomeScreen内部耗时操作导致的卡住问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 17:25:58