本地安装多个Flutter SDK版本埋的一个坑
2022-03-11 本文已影响0人
七夜98
将Flutter module 嵌入到原生做混合开发时,遇到一个奇怪现象,模拟器能正常跑起来,但一运行到真机,进入到flutter模块就直接白屏。
通过查看控制台打印的log,发现了如下错误信息:
[VERBOSE-2:shell.cc(103)] Dart Error: Can't load Kernel binary: Invalid SDK hash.
[VERBOSE-2:dart_isolate.cc(171)] Could not prepare isolate.
[VERBOSE-2:runtime_controller.cc(415)] Could not create root isolate.
[VERBOSE-2:shell.cc(588)] Could not launch engine with configuration.
搜索最后一条信息 Could not launch engine with configuration
时看到网上给出了对应的答案:
https://github.com/flutter/flutter/issues/21221

https://stackoverflow.com/questions/50654820/flutter-could-not-prepare-to-run-the-isolate

尝试了对应的方案,无果。
接着搜索第一条信息Can't load Kernel binary: Invalid SDK hash
,总算是找到了对我有用的答案:
https://www.androidbugfix.com/2021/10/can-run-flutter-project-due-to-error.html

https://github.com/flutter/flutter/issues/67222

问题的根源就是在于我本地存在多个Flutter SDK版本,当时同一个项目需要切换不同版本时,进行对应的套件安装估计出了问题,所以就导致我在运行项目时无法正常显示。