將Flutter module 嵌入到原生做混合開發(fā)時(shí)赏陵,遇到一個(gè)奇怪現(xiàn)象屑柔,模擬器能正常跑起來沉帮,但一運(yùn)行到真機(jī)锈死,進(jìn)入到flutter模塊就直接白屏。
通過查看控制臺打印的log穆壕,發(fā)現(xiàn)了如下錯(cuò)誤信息:
[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
時(shí)看到網(wǎng)上給出了對應(yīng)的答案:
https://github.com/flutter/flutter/issues/21221
https://stackoverflow.com/questions/50654820/flutter-could-not-prepare-to-run-the-isolate
嘗試了對應(yīng)的方案待牵,無果。
接著搜索第一條信息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
問題的根源就是在于我本地存在多個(gè)Flutter SDK版本缨该,當(dāng)時(shí)同一個(gè)項(xiàng)目需要切換不同版本時(shí),進(jìn)行對應(yīng)的套件安裝估計(jì)出了問題川背,所以就導(dǎo)致我在運(yùn)行項(xiàng)目時(shí)無法正常顯示贰拿。