Android接入flutter报错:Must be able
2019-05-08 本文已影响1240人
韦东锏
开始跟进flutter项目
按照官方的文档一步步接入:https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps
运行demo,都没有问题,一切正常
当实际项目接入的时候,编译跟安装apk也正常,不过在打开flutter页面的时候,报如下的错误
[ERROR:flutter/runtime/dart_vm_data.cc(19)] VM snapshot invalid and could not be inferred from settings.
[ERROR:flutter/runtime/dart_vm.cc(241)] Could not setup VM data to bootstrap the VM from.
[ERROR:flutter/runtime/dart_vm_lifecycle.cc(89)] Could not create Dart VM instance.
[FATAL:flutter/shell/common/shell.cc(218)] Check failed: vm. Must be able to initialize the VM.
当然在官方GitHub的issue下,也有很多的讨论,相关的方法也尝试过,但是没有生效
由于demo是正常的,项目是有异常,对比apk,发现项目的assets下缺少flutter_assets,于是把demo的apk解压,拿出里面的flutter_assets,放入项目中,运行编译,正常了
企业微信截图_b41de442-5d6a-46f6-b107-1b790f6701ac.png
网络上这种问题的解决方法太多了,很多都是无效的,故把自己的方法做个分享,供参考